OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 """ | 3 """ |
4 Copyright 2014 Google Inc. | 4 Copyright 2014 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 | 8 |
9 Test imagepair.py | 9 Test imagepair.py |
10 """ | 10 """ |
(...skipping 14 matching lines...) Expand all Loading... |
25 class ImagePairTest(unittest.TestCase): | 25 class ImagePairTest(unittest.TestCase): |
26 | 26 |
27 def setUp(self): | 27 def setUp(self): |
28 self._temp_dir = tempfile.mkdtemp() | 28 self._temp_dir = tempfile.mkdtemp() |
29 self.maxDiff = None | 29 self.maxDiff = None |
30 | 30 |
31 def tearDown(self): | 31 def tearDown(self): |
32 shutil.rmtree(self._temp_dir) | 32 shutil.rmtree(self._temp_dir) |
33 | 33 |
34 def shortDescription(self): | 34 def shortDescription(self): |
35 """Tell unittest framework to not print docstrings for test cases.""" | 35 """Tells unittest framework to not print docstrings for test cases. |
| 36 """ |
36 return None | 37 return None |
37 | 38 |
38 def test_endToEnd(self): | 39 def test_endToEnd(self): |
39 """Test ImagePair, using a real ImageDiffDB to download real images. | 40 """Tests ImagePair, using a real ImageDiffDB to download real images. |
40 | 41 |
41 TODO(epoger): Either in addition to or instead of this end-to-end test, | 42 TODO(epoger): Either in addition to or instead of this end-to-end test, |
42 we should perform some tests using either: | 43 we should perform some tests using either: |
43 1. a mock ImageDiffDB, or | 44 1. a mock ImageDiffDB, or |
44 2. a real ImageDiffDB that doesn't hit Google Storage looking for input | 45 2. a real ImageDiffDB that doesn't hit Google Storage looking for input |
45 image files (maybe a file:// IMG_URL_BASE) | 46 image files (maybe a file:// IMG_URL_BASE) |
46 """ | 47 """ |
47 # params for each self-test: | 48 # params for each self-test: |
48 # | 49 # |
49 # inputs: | 50 # inputs: |
50 # 0. imageA_relative_URL | 51 # 0. imageA_relative_URL |
51 # 1. imageB_relative_URL | 52 # 1. imageB_relative_URL |
52 # 2. expectations dict | 53 # 2. expectations dict |
53 # 3. extra_columns dict | 54 # 3. extra_columns dict |
54 # expected output: | 55 # expected output: |
55 # 4. expected result of ImagePair.as_dict() | 56 # 4. expected result of ImagePair.as_dict() |
56 selftests = [ | 57 selftests = [ |
57 [ | 58 [ |
58 # inputs: | 59 # inputs: |
59 'arcofzorro/16206093933823793653.png', | 60 'arcofzorro/16206093933823793653.png', |
60 'arcofzorro/16206093933823793653.png', | 61 'arcofzorro/16206093933823793653.png', |
61 None, | 62 None, |
62 { | 63 { |
63 'builder': 'MyBuilder', | 64 'builder': 'MyBuilder', |
64 'test': 'MyTest', | 65 'test': 'MyTest', |
65 }, | 66 }, |
66 # expected output: | 67 # expected output: |
67 { | 68 { |
68 'extraColumnValues': { | 69 'extraColumns': { |
69 'builder': 'MyBuilder', | 70 'builder': 'MyBuilder', |
70 'test': 'MyTest', | 71 'test': 'MyTest', |
71 }, | 72 }, |
72 'imageAUrl': 'arcofzorro/16206093933823793653.png', | 73 'imageAUrl': 'arcofzorro/16206093933823793653.png', |
73 'imageBUrl': 'arcofzorro/16206093933823793653.png', | 74 'imageBUrl': 'arcofzorro/16206093933823793653.png', |
74 'isDifferent': False, | 75 'isDifferent': False, |
75 }, | 76 }, |
76 ], | 77 ], |
77 | 78 |
78 [ | 79 [ |
(...skipping 29 matching lines...) Expand all Loading... |
108 'test': 'MyTest', | 109 'test': 'MyTest', |
109 }, | 110 }, |
110 # expected output: | 111 # expected output: |
111 { | 112 { |
112 'differenceData': { | 113 'differenceData': { |
113 'maxDiffPerChannel': [255, 0, 255], | 114 'maxDiffPerChannel': [255, 0, 255], |
114 'numDifferingPixels': 102400, | 115 'numDifferingPixels': 102400, |
115 'percentDifferingPixels': 100.00, | 116 'percentDifferingPixels': 100.00, |
116 'weightedDiffMeasure': 66.66666666666667, | 117 'weightedDiffMeasure': 66.66666666666667, |
117 }, | 118 }, |
118 'expectationsData': { | 119 'expectations': { |
119 'bugs': [1001, 1002], | 120 'bugs': [1001, 1002], |
120 'ignoreFailure': True, | 121 'ignoreFailure': True, |
121 }, | 122 }, |
122 'extraColumnValues': { | 123 'extraColumns': { |
123 'builder': 'MyBuilder', | 124 'builder': 'MyBuilder', |
124 'test': 'MyTest', | 125 'test': 'MyTest', |
125 }, | 126 }, |
126 'imageAUrl': | 127 'imageAUrl': |
127 'gradients_degenerate_2pt/10552995703607727960.png', | 128 'gradients_degenerate_2pt/10552995703607727960.png', |
128 'imageBUrl': | 129 'imageBUrl': |
129 'gradients_degenerate_2pt/11198253335583713230.png', | 130 'gradients_degenerate_2pt/11198253335583713230.png', |
130 'isDifferent': True, | 131 'isDifferent': True, |
131 }, | 132 }, |
132 ], | 133 ], |
(...skipping 11 matching lines...) Expand all Loading... |
144 self.assertEqual(image_pair.as_dict(), selftest[4]) | 145 self.assertEqual(image_pair.as_dict(), selftest[4]) |
145 | 146 |
146 | 147 |
147 def main(): | 148 def main(): |
148 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest) | 149 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest) |
149 unittest.TextTestRunner(verbosity=2).run(suite) | 150 unittest.TextTestRunner(verbosity=2).run(suite) |
150 | 151 |
151 | 152 |
152 if __name__ == '__main__': | 153 if __name__ == '__main__': |
153 main() | 154 main() |
OLD | NEW |