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

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

Issue 197213033: rebaseline_server: serve JSON from static file, rather than generating it live (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 9 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 """
11 11
12 # System-level imports 12 # System-level imports
13 import unittest 13 import unittest
14 14
15 # Local imports 15 # Local imports
16 import column 16 import column
17 import imagepair 17 import imagepair
18 import imagepairset 18 import imagepairset
19 19
20 20
21 BASE_URL_1 = 'http://base/url/1' 21 BASE_URL_1 = 'http://base/url/1'
22 BASE_URL_2 = 'http://base/url/2' 22 BASE_URL_2 = 'http://base/url/2'
23 DIFF_BASE_URL = 'http://diff/base/url'
23 IMAGEPAIR_1_AS_DICT = { 24 IMAGEPAIR_1_AS_DICT = {
24 imagepair.KEY__EXTRA_COLUMN_VALUES: { 25 imagepair.KEY__EXTRA_COLUMN_VALUES: {
25 'builder': 'MyBuilder', 26 'builder': 'MyBuilder',
26 'test': 'test1', 27 'test': 'test1',
27 }, 28 },
28 imagepair.KEY__IMAGE_A_URL: 'test1/1111.png', 29 imagepair.KEY__IMAGE_A_URL: 'test1/1111.png',
29 imagepair.KEY__IMAGE_B_URL: 'test1/1111.png', 30 imagepair.KEY__IMAGE_B_URL: 'test1/1111.png',
30 imagepair.KEY__IS_DIFFERENT: False, 31 imagepair.KEY__IS_DIFFERENT: False,
31 } 32 }
32 IMAGEPAIR_2_AS_DICT = { 33 IMAGEPAIR_2_AS_DICT = {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 'imageSets': { 110 'imageSets': {
110 'imageA': { 111 'imageA': {
111 'baseUrl': BASE_URL_1, 112 'baseUrl': BASE_URL_1,
112 'description': SET_A_DESCRIPTION, 113 'description': SET_A_DESCRIPTION,
113 }, 114 },
114 'imageB': { 115 'imageB': {
115 'baseUrl': BASE_URL_1, 116 'baseUrl': BASE_URL_1,
116 'description': SET_B_DESCRIPTION, 117 'description': SET_B_DESCRIPTION,
117 }, 118 },
118 'diffs': { 119 'diffs': {
119 'baseUrl': '/static/generated-images/diffs', 120 'baseUrl': DIFF_BASE_URL + '/diffs',
120 'description': 'color difference per channel', 121 'description': 'color difference per channel',
121 }, 122 },
122 'whiteDiffs': { 123 'whiteDiffs': {
123 'baseUrl': '/static/generated-images/whitediffs', 124 'baseUrl': DIFF_BASE_URL + '/whitediffs',
124 'description': 'differing pixels in white', 125 'description': 'differing pixels in white',
125 }, 126 },
126 }, 127 },
127 } 128 }
128 129
129 image_pair_set = imagepairset.ImagePairSet( 130 image_pair_set = imagepairset.ImagePairSet(
130 descriptions=(SET_A_DESCRIPTION, SET_B_DESCRIPTION)) 131 descriptions=(SET_A_DESCRIPTION, SET_B_DESCRIPTION),
132 diff_base_url=DIFF_BASE_URL)
131 for image_pair in image_pairs: 133 for image_pair in image_pairs:
132 image_pair_set.add_image_pair(image_pair) 134 image_pair_set.add_image_pair(image_pair)
133 # The 'builder' column header uses the default settings, 135 # The 'builder' column header uses the default settings,
134 # but the 'test' column header has manual adjustments. 136 # but the 'test' column header has manual adjustments.
135 image_pair_set.set_column_header_factory( 137 image_pair_set.set_column_header_factory(
136 'test', 138 'test',
137 column.ColumnHeaderFactory( 139 column.ColumnHeaderFactory(
138 header_text='which GM test', 140 header_text='which GM test',
139 header_url='http://learn/about/gm/tests', 141 header_url='http://learn/about/gm/tests',
140 is_filterable=True, 142 is_filterable=True,
141 is_sortable=False, 143 is_sortable=False,
142 include_values_and_counts=False)) 144 include_values_and_counts=False))
143 self.assertEqual(image_pair_set.as_dict(), expected_imageset_dict) 145 self.assertEqual(image_pair_set.as_dict(), expected_imageset_dict)
144 146
145 def test_mismatched_base_url(self): 147 def test_mismatched_base_url(self):
146 """Confirms that mismatched base_urls will cause an exception.""" 148 """Confirms that mismatched base_urls will cause an exception."""
147 image_pair_set = imagepairset.ImagePairSet() 149 image_pair_set = imagepairset.ImagePairSet(
150 diff_base_url=DIFF_BASE_URL)
148 image_pair_set.add_image_pair( 151 image_pair_set.add_image_pair(
149 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_1_AS_DICT)) 152 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_1_AS_DICT))
150 image_pair_set.add_image_pair( 153 image_pair_set.add_image_pair(
151 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_2_AS_DICT)) 154 MockImagePair(base_url=BASE_URL_1, dict_to_return=IMAGEPAIR_2_AS_DICT))
152 with self.assertRaises(Exception): 155 with self.assertRaises(Exception):
153 image_pair_set.add_image_pair( 156 image_pair_set.add_image_pair(
154 MockImagePair(base_url=BASE_URL_2, 157 MockImagePair(base_url=BASE_URL_2,
155 dict_to_return=IMAGEPAIR_3_AS_DICT)) 158 dict_to_return=IMAGEPAIR_3_AS_DICT))
156 159
157 160
(...skipping 14 matching lines...) Expand all
172 return self._dict_to_return 175 return self._dict_to_return
173 176
174 177
175 def main(): 178 def main():
176 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairSetTest) 179 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairSetTest)
177 unittest.TextTestRunner(verbosity=2).run(suite) 180 unittest.TextTestRunner(verbosity=2).run(suite)
178 181
179 182
180 if __name__ == '__main__': 183 if __name__ == '__main__':
181 main() 184 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698