OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Tests for module json_summary_combiner.py""" | 6 """Tests for module json_summary_combiner.py""" |
7 | 7 |
8 import filecmp | 8 import filecmp |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 27 matching lines...) Expand all Loading... |
38 file_count += 1 | 38 file_count += 1 |
39 self.assertEquals(file_info.file_name, | 39 self.assertEquals(file_info.file_name, |
40 'file%s_%s.png' % (slave_name, file_count)) | 40 'file%s_%s.png' % (slave_name, file_count)) |
41 self.assertEquals(file_info.skp_location, | 41 self.assertEquals(file_info.skp_location, |
42 'http://storage.cloud.google.com/dummy-bucket/skps' | 42 'http://storage.cloud.google.com/dummy-bucket/skps' |
43 '/%s/file%s_.skp' % (slave_name, slave_name)) | 43 '/%s/file%s_.skp' % (slave_name, slave_name)) |
44 self.assertEquals(file_info.num_pixels_differing, | 44 self.assertEquals(file_info.num_pixels_differing, |
45 int('%s%s1' % (slave_num, file_count))) | 45 int('%s%s1' % (slave_num, file_count))) |
46 self.assertEquals(file_info.percent_pixels_differing, | 46 self.assertEquals(file_info.percent_pixels_differing, |
47 int('%s%s2' % (slave_num, file_count))) | 47 int('%s%s2' % (slave_num, file_count))) |
48 self.assertEquals(file_info.weighted_diff_measure, | |
49 int('%s%s3' % (slave_num, file_count))) | |
50 self.assertEquals(file_info.max_diff_per_channel, | 48 self.assertEquals(file_info.max_diff_per_channel, |
51 int('%s%s4' % (slave_num, file_count))) | 49 int('%s%s4' % (slave_num, file_count))) |
52 | 50 |
53 self.assertEquals( | 51 self.assertEquals( |
54 slave_info.skps_location, | 52 slave_info.skps_location, |
55 'gs://dummy-bucket/skps/%s' % slave_name) | 53 'gs://dummy-bucket/skps/%s' % slave_name) |
56 self.assertEquals( | 54 self.assertEquals( |
57 slave_info.files_location_nopatch, | 55 slave_info.files_location_nopatch, |
58 'gs://dummy-bucket/output-dir/%s/nopatch-images' % slave_name) | 56 'gs://dummy-bucket/output-dir/%s/nopatch-images' % slave_name) |
59 self.assertEquals( | 57 self.assertEquals( |
(...skipping 10 matching lines...) Expand all Loading... |
70 | 68 |
71 def _get_test_slave_name_to_info(self): | 69 def _get_test_slave_name_to_info(self): |
72 slave_name_to_info = { | 70 slave_name_to_info = { |
73 'slave1': json_summary_combiner.SlaveInfo( | 71 'slave1': json_summary_combiner.SlaveInfo( |
74 slave_name='slave1', | 72 slave_name='slave1', |
75 failed_files=[ | 73 failed_files=[ |
76 json_summary_combiner.FileInfo( | 74 json_summary_combiner.FileInfo( |
77 'fileslave1_1.png', | 75 'fileslave1_1.png', |
78 'http://storage.cloud.google.com/dummy-bucket/skps/slave1/' | 76 'http://storage.cloud.google.com/dummy-bucket/skps/slave1/' |
79 'fileslave1_.skp', | 77 'fileslave1_.skp', |
80 111, 112, 113, 114, 115), | 78 111, 112, 114, 115), |
81 json_summary_combiner.FileInfo( | 79 json_summary_combiner.FileInfo( |
82 'fileslave1_2.png', | 80 'fileslave1_2.png', |
83 'http://storage.cloud.google.com/dummy-bucket/skps/slave1/' | 81 'http://storage.cloud.google.com/dummy-bucket/skps/slave1/' |
84 'fileslave1_.skp', | 82 'fileslave1_.skp', |
85 121, 122, 123, 124, 125)], | 83 121, 122, 124, 125)], |
86 skps_location='gs://dummy-bucket/skps/slave1', | 84 skps_location='gs://dummy-bucket/skps/slave1', |
87 files_location_diffs='gs://dummy-bucket/slave1/diffs', | 85 files_location_diffs='gs://dummy-bucket/slave1/diffs', |
88 files_location_whitediffs='gs://dummy-bucket/slave1/whitediffs', | 86 files_location_whitediffs='gs://dummy-bucket/slave1/whitediffs', |
89 files_location_nopatch='gs://dummy-bucket/slave1/nopatch', | 87 files_location_nopatch='gs://dummy-bucket/slave1/nopatch', |
90 files_location_withpatch='gs://dummy-bucket/slave1/withpatch'), | 88 files_location_withpatch='gs://dummy-bucket/slave1/withpatch'), |
91 'slave2': json_summary_combiner.SlaveInfo( | 89 'slave2': json_summary_combiner.SlaveInfo( |
92 slave_name='slave2', | 90 slave_name='slave2', |
93 failed_files=[ | 91 failed_files=[ |
94 json_summary_combiner.FileInfo( | 92 json_summary_combiner.FileInfo( |
95 'fileslave2_1.png', | 93 'fileslave2_1.png', |
96 'http://storage.cloud.google.com/dummy-bucket/skps/slave2/' | 94 'http://storage.cloud.google.com/dummy-bucket/skps/slave2/' |
97 'fileslave2_.skp', | 95 'fileslave2_.skp', |
98 211, 212, 213, 214, 215)], | 96 211, 212, 214, 215)], |
99 skps_location='gs://dummy-bucket/skps/slave2', | 97 skps_location='gs://dummy-bucket/skps/slave2', |
100 files_location_diffs='gs://dummy-bucket/slave2/diffs', | 98 files_location_diffs='gs://dummy-bucket/slave2/diffs', |
101 files_location_whitediffs='gs://dummy-bucket/slave2/whitediffs', | 99 files_location_whitediffs='gs://dummy-bucket/slave2/whitediffs', |
102 files_location_nopatch='gs://dummy-bucket/slave2/nopatch', | 100 files_location_nopatch='gs://dummy-bucket/slave2/nopatch', |
103 files_location_withpatch='gs://dummy-bucket/slave2/withpatch'), | 101 files_location_withpatch='gs://dummy-bucket/slave2/withpatch'), |
104 'slave3': json_summary_combiner.SlaveInfo( | 102 'slave3': json_summary_combiner.SlaveInfo( |
105 slave_name='slave3', | 103 slave_name='slave3', |
106 failed_files=[ | 104 failed_files=[ |
107 json_summary_combiner.FileInfo( | 105 json_summary_combiner.FileInfo( |
108 'fileslave3_1.png', | 106 'fileslave3_1.png', |
109 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' | 107 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' |
110 'fileslave3_.skp', | 108 'fileslave3_.skp', |
111 311, 312, 313, 314, 315), | 109 311, 312, 314, 315), |
112 json_summary_combiner.FileInfo( | 110 json_summary_combiner.FileInfo( |
113 'fileslave3_2.png', | 111 'fileslave3_2.png', |
114 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' | 112 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' |
115 'fileslave3_.skp', | 113 'fileslave3_.skp', |
116 321, 322, 323, 324, 325), | 114 321, 322, 324, 325), |
117 json_summary_combiner.FileInfo( | 115 json_summary_combiner.FileInfo( |
118 'fileslave3_3.png', | 116 'fileslave3_3.png', |
119 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' | 117 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' |
120 'fileslave3_.skp', | 118 'fileslave3_.skp', |
121 331, 332, 333, 334, 335), | 119 331, 332, 334, 335), |
122 json_summary_combiner.FileInfo( | 120 json_summary_combiner.FileInfo( |
123 'fileslave3_4.png', | 121 'fileslave3_4.png', |
124 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' | 122 'http://storage.cloud.google.com/dummy-bucket/skps/slave3/' |
125 'fileslave3_.skp', | 123 'fileslave3_.skp', |
126 341, 342, 343, 344, 345)], | 124 341, 342, 344, 345)], |
127 skps_location='gs://dummy-bucket/skps/slave3', | 125 skps_location='gs://dummy-bucket/skps/slave3', |
128 files_location_diffs='gs://dummy-bucket/slave3/diffs', | 126 files_location_diffs='gs://dummy-bucket/slave3/diffs', |
129 files_location_whitediffs='gs://dummy-bucket/slave3/whitediffs', | 127 files_location_whitediffs='gs://dummy-bucket/slave3/whitediffs', |
130 files_location_nopatch='gs://dummy-bucket/slave3/nopatch', | 128 files_location_nopatch='gs://dummy-bucket/slave3/nopatch', |
131 files_location_withpatch='gs://dummy-bucket/slave3/withpatch') | 129 files_location_withpatch='gs://dummy-bucket/slave3/withpatch') |
132 } | 130 } |
133 return slave_name_to_info | 131 return slave_name_to_info |
134 | 132 |
135 def test_OutputToHTML_WithDifferences_WithAbsoluteUrl(self): | 133 def test_OutputToHTML_WithDifferences_WithAbsoluteUrl(self): |
136 slave_name_to_info = self._get_test_slave_name_to_info() | 134 slave_name_to_info = self._get_test_slave_name_to_info() |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 183 |
186 html_expected_dir = os.path.join(self._test_data_dir, 'html_outputs', | 184 html_expected_dir = os.path.join(self._test_data_dir, 'html_outputs', |
187 'nodifferences') | 185 'nodifferences') |
188 self.assertTrue( | 186 self.assertTrue( |
189 filecmp.cmp(os.path.join(html_expected_dir, 'index.html'), | 187 filecmp.cmp(os.path.join(html_expected_dir, 'index.html'), |
190 os.path.join(self._actual_html_dir, 'index.html'))) | 188 os.path.join(self._actual_html_dir, 'index.html'))) |
191 | 189 |
192 | 190 |
193 if __name__ == '__main__': | 191 if __name__ == '__main__': |
194 unittest.main() | 192 unittest.main() |
195 | |
OLD | NEW |