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 return None | 36 return None |
37 | 37 |
38 def test_endToEnd(self): | 38 def test_endToEnd(self): |
39 """Test ImagePair, using a real ImageDiffDB to download real images. | 39 """Tests ImagePair, using a real ImageDiffDB to download real images. |
40 | 40 |
41 TODO(epoger): Either in addition to or instead of this end-to-end test, | 41 TODO(epoger): Either in addition to or instead of this end-to-end test, |
42 we should perform some tests using either: | 42 we should perform some tests using either: |
43 1. a mock ImageDiffDB, or | 43 1. a mock ImageDiffDB, or |
44 2. a real ImageDiffDB that doesn't hit Google Storage looking for input | 44 2. a real ImageDiffDB that doesn't hit Google Storage looking for input |
45 image files (maybe a file:// IMG_URL_BASE) | 45 image files (maybe a file:// IMG_URL_BASE) |
46 """ | 46 """ |
47 # params for each self-test: | 47 # params for each self-test: |
48 # | 48 # |
49 # inputs: | 49 # inputs: |
50 # 0. imageA_relative_URL | 50 # 0. imageA_relative_URL |
51 # 1. imageB_relative_URL | 51 # 1. imageB_relative_URL |
52 # 2. expectations dict | 52 # 2. expectations dict |
53 # 3. extra_columns dict | 53 # 3. extra_columns dict |
54 # expected output: | 54 # expected output: |
55 # 4. expected result of ImagePair.as_dict() | 55 # 4. expected result of ImagePair.as_dict() |
56 selftests = [ | 56 selftests = [ |
57 [ | 57 [ |
58 # inputs: | 58 # inputs: |
59 'arcofzorro/16206093933823793653.png', | 59 'arcofzorro/16206093933823793653.png', |
60 'arcofzorro/16206093933823793653.png', | 60 'arcofzorro/16206093933823793653.png', |
61 None, | 61 None, |
62 { | 62 { |
63 'builder': 'MyBuilder', | 63 'builder': 'MyBuilder', |
64 'test': 'MyTest', | 64 'test': 'MyTest', |
65 }, | 65 }, |
66 # expected output: | 66 # expected output: |
67 { | 67 { |
68 'extraColumnValues': { | 68 'extraColumns': { |
69 'builder': 'MyBuilder', | 69 'builder': 'MyBuilder', |
70 'test': 'MyTest', | 70 'test': 'MyTest', |
71 }, | 71 }, |
72 'imageAUrl': 'arcofzorro/16206093933823793653.png', | 72 'imageAUrl': 'arcofzorro/16206093933823793653.png', |
73 'imageBUrl': 'arcofzorro/16206093933823793653.png', | 73 'imageBUrl': 'arcofzorro/16206093933823793653.png', |
74 'isDifferent': False, | 74 'isDifferent': False, |
75 }, | 75 }, |
76 ], | 76 ], |
77 | 77 |
78 [ | 78 [ |
(...skipping 29 matching lines...) Expand all Loading... |
108 'test': 'MyTest', | 108 'test': 'MyTest', |
109 }, | 109 }, |
110 # expected output: | 110 # expected output: |
111 { | 111 { |
112 'differenceData': { | 112 'differenceData': { |
113 'maxDiffPerChannel': [255, 0, 255], | 113 'maxDiffPerChannel': [255, 0, 255], |
114 'numDifferingPixels': 102400, | 114 'numDifferingPixels': 102400, |
115 'percentDifferingPixels': 100.00, | 115 'percentDifferingPixels': 100.00, |
116 'weightedDiffMeasure': 66.66666666666667, | 116 'weightedDiffMeasure': 66.66666666666667, |
117 }, | 117 }, |
118 'expectationsData': { | 118 'expectations': { |
119 'bugs': [1001, 1002], | 119 'bugs': [1001, 1002], |
120 'ignoreFailure': True, | 120 'ignoreFailure': True, |
121 }, | 121 }, |
122 'extraColumnValues': { | 122 'extraColumns': { |
123 'builder': 'MyBuilder', | 123 'builder': 'MyBuilder', |
124 'test': 'MyTest', | 124 'test': 'MyTest', |
125 }, | 125 }, |
126 'imageAUrl': | 126 'imageAUrl': |
127 'gradients_degenerate_2pt/10552995703607727960.png', | 127 'gradients_degenerate_2pt/10552995703607727960.png', |
128 'imageBUrl': | 128 'imageBUrl': |
129 'gradients_degenerate_2pt/11198253335583713230.png', | 129 'gradients_degenerate_2pt/11198253335583713230.png', |
130 'isDifferent': True, | 130 'isDifferent': True, |
131 }, | 131 }, |
132 ], | 132 ], |
(...skipping 11 matching lines...) Expand all Loading... |
144 self.assertEqual(image_pair.as_dict(), selftest[4]) | 144 self.assertEqual(image_pair.as_dict(), selftest[4]) |
145 | 145 |
146 | 146 |
147 def main(): | 147 def main(): |
148 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest) | 148 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest) |
149 unittest.TextTestRunner(verbosity=2).run(suite) | 149 unittest.TextTestRunner(verbosity=2).run(suite) |
150 | 150 |
151 | 151 |
152 if __name__ == '__main__': | 152 if __name__ == '__main__': |
153 main() | 153 main() |
OLD | NEW |