commit-bot@chromium.org | 3eb77e4 | 2014-04-04 16:40:25 +0000 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | """ |
| 4 | Copyright 2014 Google Inc. |
| 5 | |
| 6 | Use of this source code is governed by a BSD-style license that can be |
| 7 | found in the LICENSE file. |
| 8 | |
| 9 | Test results.py |
| 10 | |
| 11 | """ |
| 12 | |
| 13 | # Imports from within Skia |
| 14 | import base_unittest |
| 15 | import results |
| 16 | |
| 17 | |
| 18 | class ResultsTest(base_unittest.TestCase): |
| 19 | |
| 20 | def test_combine_subdicts_typical(self): |
| 21 | """Test combine_subdicts() with no merge conflicts. """ |
| 22 | input_dict = { |
| 23 | "failed" : { |
| 24 | "changed.png" : [ "bitmap-64bitMD5", 8891695120562235492 ], |
| 25 | }, |
| 26 | "no-comparison" : { |
| 27 | "unchanged.png" : [ "bitmap-64bitMD5", 11092453015575919668 ], |
| 28 | } |
| 29 | } |
| 30 | expected_output_dict = { |
| 31 | "changed.png" : [ "bitmap-64bitMD5", 8891695120562235492 ], |
| 32 | "unchanged.png" : [ "bitmap-64bitMD5", 11092453015575919668 ], |
| 33 | } |
| 34 | actual_output_dict = results.BaseComparisons.combine_subdicts( |
| 35 | input_dict=input_dict) |
| 36 | self.assertEqual(actual_output_dict, expected_output_dict) |
| 37 | |
| 38 | def test_combine_subdicts_with_merge_conflict(self): |
| 39 | """Test combine_subdicts() with a merge conflict. """ |
| 40 | input_dict = { |
| 41 | "failed" : { |
| 42 | "changed.png" : [ "bitmap-64bitMD5", 8891695120562235492 ], |
| 43 | }, |
| 44 | "no-comparison" : { |
| 45 | "changed.png" : [ "bitmap-64bitMD5", 11092453015575919668 ], |
| 46 | } |
| 47 | } |
| 48 | with self.assertRaises(Exception): |
| 49 | actual_output_dict = results.BaseComparisons.combine_subdicts( |
| 50 | input_dict=input_dict) |
| 51 | |
| 52 | |
| 53 | def main(): |
| 54 | base_unittest.main(ResultsTest) |
| 55 | |
| 56 | |
| 57 | if __name__ == '__main__': |
| 58 | main() |