| 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 """ |
| 11 | 11 |
| 12 # System-level imports | 12 # System-level imports |
| 13 import shutil | 13 import shutil |
| 14 import tempfile | 14 import tempfile |
| 15 import unittest | 15 import unittest |
| 16 | 16 |
| 17 # Local imports | 17 # Local imports |
| 18 import imagediffdb | 18 import imagediffdb |
| 19 import imagepair | 19 import imagepair |
| 20 | 20 |
| 21 | 21 |
| 22 IMG_URL_BASE = ('http://chromium-skia-gm.commondatastorage.googleapis.com/' | 22 IMG_URL_BASE = ('http://chromium-skia-gm.commondatastorage.googleapis.com/' |
| 23 'gm/bitmap-64bitMD5/') | 23 'gm/bitmap-64bitMD5/') |
| 24 | 24 |
| 25 | 25 |
| 26 class ImagePairTest(unittest.TestCase): | 26 class ImagePairTest(unittest.TestCase): |
| 27 | 27 |
| 28 def setUp(self): | 28 def setUp(self): |
| 29 self._temp_dir = tempfile.mkdtemp() | 29 self.temp_dir = tempfile.mkdtemp() |
| 30 self.maxDiff = None | 30 self.maxDiff = None |
| 31 | 31 |
| 32 def tearDown(self): | 32 def tearDown(self): |
| 33 shutil.rmtree(self._temp_dir) | 33 shutil.rmtree(self.temp_dir) |
| 34 | 34 |
| 35 def shortDescription(self): | 35 def shortDescription(self): |
| 36 """Tells unittest framework to not print docstrings for test cases.""" | 36 """Tells unittest framework to not print docstrings for test cases.""" |
| 37 return None | 37 return None |
| 38 | 38 |
| 39 def test_endToEnd(self): | 39 def test_endToEnd(self): |
| 40 """Tests ImagePair, using a real ImageDiffDB to download real images. | 40 """Tests ImagePair, using a real ImageDiffDB to download real images. |
| 41 | 41 |
| 42 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, |
| 43 we should perform some tests using either: | 43 we should perform some tests using either: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 'builder': 'MyBuilder', | 156 'builder': 'MyBuilder', |
| 157 'test': 'MyTest', | 157 'test': 'MyTest', |
| 158 }, | 158 }, |
| 159 'imageAUrl': 'arcofzorro/16206093933823793653.png', | 159 'imageAUrl': 'arcofzorro/16206093933823793653.png', |
| 160 'imageBUrl': 'nonexistentDir/111111.png', | 160 'imageBUrl': 'nonexistentDir/111111.png', |
| 161 'isDifferent': True, | 161 'isDifferent': True, |
| 162 }, | 162 }, |
| 163 ], | 163 ], |
| 164 ] | 164 ] |
| 165 | 165 |
| 166 db = imagediffdb.ImageDiffDB(self._temp_dir) | 166 db = imagediffdb.ImageDiffDB(self.temp_dir) |
| 167 for selftest in selftests: | 167 for selftest in selftests: |
| 168 image_pair = imagepair.ImagePair( | 168 image_pair = imagepair.ImagePair( |
| 169 image_diff_db=db, | 169 image_diff_db=db, |
| 170 base_url=IMG_URL_BASE, | 170 base_url=IMG_URL_BASE, |
| 171 imageA_relative_url=selftest[0], | 171 imageA_relative_url=selftest[0], |
| 172 imageB_relative_url=selftest[1], | 172 imageB_relative_url=selftest[1], |
| 173 expectations=selftest[2], | 173 expectations=selftest[2], |
| 174 extra_columns=selftest[3]) | 174 extra_columns=selftest[3]) |
| 175 self.assertEqual(image_pair.as_dict(), selftest[4]) | 175 self.assertEqual(image_pair.as_dict(), selftest[4]) |
| 176 | 176 |
| 177 | 177 |
| 178 def main(): | 178 def main(): |
| 179 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest) | 179 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest) |
| 180 unittest.TextTestRunner(verbosity=2).run(suite) | 180 unittest.TextTestRunner(verbosity=2).run(suite) |
| 181 | 181 |
| 182 | 182 |
| 183 if __name__ == '__main__': | 183 if __name__ == '__main__': |
| 184 main() | 184 main() |
| OLD | NEW |