| 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 compare_rendered_pictures.py | 9 Test compare_rendered_pictures.py |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( | 58 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( |
| 59 setA_dirs=[os.path.join(self.temp_dir, setA_subdir)], | 59 setA_dirs=[os.path.join(self.temp_dir, setA_subdir)], |
| 60 setB_dirs=[os.path.join(self.temp_dir, setB_subdir)], | 60 setB_dirs=[os.path.join(self.temp_dir, setB_subdir)], |
| 61 setA_section=gm_json.JSONKEY_ACTUALRESULTS, | 61 setA_section=gm_json.JSONKEY_ACTUALRESULTS, |
| 62 setB_section=gm_json.JSONKEY_ACTUALRESULTS, | 62 setB_section=gm_json.JSONKEY_ACTUALRESULTS, |
| 63 image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir), | 63 image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir), |
| 64 image_base_gs_url='gs://fakebucket/fake/path', | 64 image_base_gs_url='gs://fakebucket/fake/path', |
| 65 diff_base_url='/static/generated-images') | 65 diff_base_url='/static/generated-images') |
| 66 results_obj.get_timestamp = mock_get_timestamp | 66 results_obj.get_timestamp = mock_get_timestamp |
| 67 | 67 |
| 68 # Overwrite elements within the results that change from one test run |
| 69 # to the next. |
| 70 # pylint: disable=W0212 |
| 71 results_obj._setA_descriptions[results.KEY__SET_DESCRIPTIONS__DIR] = [ |
| 72 'before-patch-fake-dir'] |
| 73 results_obj._setB_descriptions[results.KEY__SET_DESCRIPTIONS__DIR] = [ |
| 74 'after-patch-fake-dir'] |
| 75 |
| 68 gm_json.WriteToFile( | 76 gm_json.WriteToFile( |
| 69 results_obj.get_packaged_results_of_type( | 77 results_obj.get_packaged_results_of_type( |
| 70 results.KEY__HEADER__RESULTS_ALL), | 78 results.KEY__HEADER__RESULTS_ALL), |
| 71 os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json')) | 79 os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json')) |
| 72 | 80 |
| 73 def test_repo_url(self): | 81 def test_repo_url(self): |
| 74 """Use repo: URL to specify summary files.""" | 82 """Use repo: URL to specify summary files.""" |
| 75 base_repo_url = 'repo:gm/rebaseline_server/testdata/inputs/skp-summaries' | 83 base_repo_url = 'repo:gm/rebaseline_server/testdata/inputs/skp-summaries' |
| 76 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( | 84 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( |
| 77 setA_dirs=[posixpath.join(base_repo_url, 'expectations')], | 85 setA_dirs=[posixpath.join(base_repo_url, 'expectations')], |
| 78 setB_dirs=[posixpath.join(base_repo_url, 'actuals')], | 86 setB_dirs=[posixpath.join(base_repo_url, 'actuals')], |
| 79 setA_section=gm_json.JSONKEY_EXPECTEDRESULTS, | 87 setA_section=gm_json.JSONKEY_EXPECTEDRESULTS, |
| 80 setB_section=gm_json.JSONKEY_ACTUALRESULTS, | 88 setB_section=gm_json.JSONKEY_ACTUALRESULTS, |
| 81 image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir), | 89 image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir), |
| 82 image_base_gs_url='gs://fakebucket/fake/path', | 90 image_base_gs_url='gs://fakebucket/fake/path', |
| 83 diff_base_url='/static/generated-images') | 91 diff_base_url='/static/generated-images') |
| 84 results_obj.get_timestamp = mock_get_timestamp | 92 results_obj.get_timestamp = mock_get_timestamp |
| 85 | 93 |
| 94 # Overwrite elements within the results that change from one test run |
| 95 # to the next. |
| 96 # pylint: disable=W0212 |
| 97 results_obj._setA_descriptions\ |
| 98 [results.KEY__SET_DESCRIPTIONS__REPO_REVISION] = 'fake-repo-revision' |
| 99 results_obj._setB_descriptions\ |
| 100 [results.KEY__SET_DESCRIPTIONS__REPO_REVISION] = 'fake-repo-revision' |
| 101 |
| 86 gm_json.WriteToFile( | 102 gm_json.WriteToFile( |
| 87 results_obj.get_packaged_results_of_type( | 103 results_obj.get_packaged_results_of_type( |
| 88 results.KEY__HEADER__RESULTS_ALL), | 104 results.KEY__HEADER__RESULTS_ALL), |
| 89 os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json')) | 105 os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json')) |
| 90 | 106 |
| 91 def _generate_skps_and_run_render_pictures(self, subdir, skpdict): | 107 def _generate_skps_and_run_render_pictures(self, subdir, skpdict): |
| 92 """Generate SKPs and run render_pictures on them. | 108 """Generate SKPs and run render_pictures on them. |
| 93 | 109 |
| 94 Args: | 110 Args: |
| 95 subdir: subdirectory (within self.temp_dir) to write all files into | 111 subdir: subdirectory (within self.temp_dir) to write all files into |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 """Mock version of BaseComparisons.get_timestamp() for testing.""" | 155 """Mock version of BaseComparisons.get_timestamp() for testing.""" |
| 140 return 12345678 | 156 return 12345678 |
| 141 | 157 |
| 142 | 158 |
| 143 def main(): | 159 def main(): |
| 144 base_unittest.main(CompareRenderedPicturesTest) | 160 base_unittest.main(CompareRenderedPicturesTest) |
| 145 | 161 |
| 146 | 162 |
| 147 if __name__ == '__main__': | 163 if __name__ == '__main__': |
| 148 main() | 164 main() |
| OLD | NEW |