Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(993)

Side by Side Diff: gm/rebaseline_server/imagepairset_test.py

Issue 479613002: Add ability to output ImageBaseGSUrl to render_picture and use in rebaseline server (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix render_pictures_test after rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 imagepairset.py 9 Test imagepairset.py
10 """ 10 """
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 self.maxDiff = None # do not truncate diffs when tests fail 72 self.maxDiff = None # do not truncate diffs when tests fail
73 73
74 def shortDescription(self): 74 def shortDescription(self):
75 """Tells unittest framework to not print docstrings for test cases.""" 75 """Tells unittest framework to not print docstrings for test cases."""
76 return None 76 return None
77 77
78 def test_success(self): 78 def test_success(self):
79 """Assembles some ImagePairs into an ImagePairSet, and validates results. 79 """Assembles some ImagePairs into an ImagePairSet, and validates results.
80 """ 80 """
81 image_pairs = [ 81 image_pairs = [
82 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_1_AS_DICT), 82 MockImagePair(imageA_base_url=BASE_URL_1, imageB_base_url=BASE_URL_1,
83 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_2_AS_DICT), 83 dict_to_return=IMAGEPAIR_1_AS_DICT),
84 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_3_AS_DICT), 84 MockImagePair(imageA_base_url=BASE_URL_1, imageB_base_url=BASE_URL_1,
85 dict_to_return=IMAGEPAIR_2_AS_DICT),
86 MockImagePair(imageA_base_url=BASE_URL_1, imageB_base_url=BASE_URL_1,
87 dict_to_return=IMAGEPAIR_3_AS_DICT),
85 ] 88 ]
86 expected_imageset_dict = { 89 expected_imageset_dict = {
87 'extraColumnHeaders': { 90 'extraColumnHeaders': {
88 'builder': { 91 'builder': {
89 'headerText': 'builder', 92 'headerText': 'builder',
90 'isFilterable': True, 93 'isFilterable': True,
91 'isSortable': True, 94 'isSortable': True,
92 'useFreeformFilter': False, 95 'useFreeformFilter': False,
93 'valuesAndCounts': [('MyBuilder', 3)], 96 'valuesAndCounts': [('MyBuilder', 3)],
94 }, 97 },
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 header_url='http://learn/about/gm/tests', 146 header_url='http://learn/about/gm/tests',
144 is_filterable=True, 147 is_filterable=True,
145 is_sortable=False)) 148 is_sortable=False))
146 self.assertEqual(image_pair_set.as_dict(), expected_imageset_dict) 149 self.assertEqual(image_pair_set.as_dict(), expected_imageset_dict)
147 150
148 def test_mismatched_base_url(self): 151 def test_mismatched_base_url(self):
149 """Confirms that mismatched base_urls will cause an exception.""" 152 """Confirms that mismatched base_urls will cause an exception."""
150 image_pair_set = imagepairset.ImagePairSet( 153 image_pair_set = imagepairset.ImagePairSet(
151 diff_base_url=DIFF_BASE_URL) 154 diff_base_url=DIFF_BASE_URL)
152 image_pair_set.add_image_pair( 155 image_pair_set.add_image_pair(
153 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_1_AS_DICT)) 156 MockImagePair(imageA_base_url=BASE_URL_1, imageB_base_url=BASE_URL_1,
157 dict_to_return=IMAGEPAIR_1_AS_DICT))
154 image_pair_set.add_image_pair( 158 image_pair_set.add_image_pair(
155 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_2_AS_DICT)) 159 MockImagePair(imageA_base_url=BASE_URL_1, imageB_base_url=BASE_URL_1,
160 dict_to_return=IMAGEPAIR_2_AS_DICT))
156 with self.assertRaises(Exception): 161 with self.assertRaises(Exception):
157 image_pair_set.add_image_pair( 162 image_pair_set.add_image_pair(
158 MockImagePair(base_url=BASE_URL_2, 163 MockImagePair(imageA_base_url=BASE_URL_2, imageB_base_url=BASE_URL_2,
159 dict_to_return=IMAGEPAIR_3_AS_DICT)) 164 dict_to_return=IMAGEPAIR_3_AS_DICT))
160 165
161 def test_missing_column_ids(self): 166 def test_missing_column_ids(self):
162 """Confirms that passing truncated column_ids_in_order to as_dict() 167 """Confirms that passing truncated column_ids_in_order to as_dict()
163 will cause an exception.""" 168 will cause an exception."""
164 image_pair_set = imagepairset.ImagePairSet( 169 image_pair_set = imagepairset.ImagePairSet(
165 diff_base_url=DIFF_BASE_URL) 170 diff_base_url=DIFF_BASE_URL)
166 image_pair_set.add_image_pair( 171 image_pair_set.add_image_pair(
167 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_1_AS_DICT)) 172 MockImagePair(imageA_base_url=BASE_URL_1, imageB_base_url=BASE_URL_1,
173 dict_to_return=IMAGEPAIR_1_AS_DICT))
168 image_pair_set.add_image_pair( 174 image_pair_set.add_image_pair(
169 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_2_AS_DICT)) 175 MockImagePair(imageA_base_url=BASE_URL_1, imageB_base_url=BASE_URL_1,
176 dict_to_return=IMAGEPAIR_2_AS_DICT))
170 # Call as_dict() with default or reasonable column_ids_in_order. 177 # Call as_dict() with default or reasonable column_ids_in_order.
171 image_pair_set.as_dict() 178 image_pair_set.as_dict()
172 image_pair_set.as_dict(column_ids_in_order=['test', 'builder']) 179 image_pair_set.as_dict(column_ids_in_order=['test', 'builder'])
173 image_pair_set.as_dict(column_ids_in_order=['test', 'builder', 'extra']) 180 image_pair_set.as_dict(column_ids_in_order=['test', 'builder', 'extra'])
174 # Call as_dict() with not enough column_ids. 181 # Call as_dict() with not enough column_ids.
175 with self.assertRaises(Exception): 182 with self.assertRaises(Exception):
176 image_pair_set.as_dict(column_ids_in_order=['builder']) 183 image_pair_set.as_dict(column_ids_in_order=['builder'])
177 184
178 185
179 class MockImagePair(object): 186 class MockImagePair(object):
180 """Mock ImagePair object, which will return canned results.""" 187 """Mock ImagePair object, which will return canned results."""
181 def __init__(self, base_url, dict_to_return): 188 def __init__(self, imageA_base_url, imageB_base_url, dict_to_return):
182 """ 189 """
183 Args: 190 Args:
184 base_url: base_url attribute for this object 191 base_url: base_url attribute for this object
185 dict_to_return: dictionary to return from as_dict() 192 dict_to_return: dictionary to return from as_dict()
186 """ 193 """
187 self.base_url = base_url 194 self.imageA_base_url = imageA_base_url
195 self.imageB_base_url = imageB_base_url
188 self.extra_columns_dict = dict_to_return.get( 196 self.extra_columns_dict = dict_to_return.get(
189 imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS, None) 197 imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS, None)
190 self._dict_to_return = dict_to_return 198 self._dict_to_return = dict_to_return
191 199
192 def as_dict(self): 200 def as_dict(self):
193 return self._dict_to_return 201 return self._dict_to_return
194 202
195 203
196 def main(): 204 def main():
197 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairSetTest) 205 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairSetTest)
198 unittest.TextTestRunner(verbosity=2).run(suite) 206 unittest.TextTestRunner(verbosity=2).run(suite)
199 207
200 208
201 if __name__ == '__main__': 209 if __name__ == '__main__':
202 main() 210 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698