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

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

Issue 287473002: rename rebaseline_server JSON constants to be more consistent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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 DIFF_BASE_URL = 'http://diff/base/url'
24 IMAGEPAIR_1_AS_DICT = { 24 IMAGEPAIR_1_AS_DICT = {
25 imagepair.KEY__EXTRA_COLUMN_VALUES: { 25 imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS: {
26 'builder': 'MyBuilder', 26 'builder': 'MyBuilder',
27 'test': 'test1', 27 'test': 'test1',
28 }, 28 },
29 imagepair.KEY__IMAGE_A_URL: 'test1/1111.png', 29 imagepair.KEY__IMAGEPAIRS__IMAGE_A_URL: 'test1/1111.png',
30 imagepair.KEY__IMAGE_B_URL: 'test1/1111.png', 30 imagepair.KEY__IMAGEPAIRS__IMAGE_B_URL: 'test1/1111.png',
31 imagepair.KEY__IS_DIFFERENT: False, 31 imagepair.KEY__IMAGEPAIRS__IS_DIFFERENT: False,
32 } 32 }
33 IMAGEPAIR_2_AS_DICT = { 33 IMAGEPAIR_2_AS_DICT = {
34 imagepair.KEY__DIFFERENCE_DATA: { 34 imagepair.KEY__IMAGEPAIRS__DIFFERENCES: {
35 'maxDiffPerChannel': [1, 2, 3], 35 'maxDiffPerChannel': [1, 2, 3],
36 'numDifferingPixels': 111, 36 'numDifferingPixels': 111,
37 'percentDifferingPixels': 22.222, 37 'percentDifferingPixels': 22.222,
38 'weightedDiffMeasure': 33.333, 38 'weightedDiffMeasure': 33.333,
39 }, 39 },
40 imagepair.KEY__EXTRA_COLUMN_VALUES: { 40 imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS: {
41 'builder': 'MyBuilder', 41 'builder': 'MyBuilder',
42 'test': 'test2', 42 'test': 'test2',
43 }, 43 },
44 imagepair.KEY__IMAGE_A_URL: 'test2/2222.png', 44 imagepair.KEY__IMAGEPAIRS__IMAGE_A_URL: 'test2/2222.png',
45 imagepair.KEY__IMAGE_B_URL: 'test2/22223.png', 45 imagepair.KEY__IMAGEPAIRS__IMAGE_B_URL: 'test2/22223.png',
46 imagepair.KEY__IS_DIFFERENT: True, 46 imagepair.KEY__IMAGEPAIRS__IS_DIFFERENT: True,
47 } 47 }
48 IMAGEPAIR_3_AS_DICT = { 48 IMAGEPAIR_3_AS_DICT = {
49 imagepair.KEY__DIFFERENCE_DATA: { 49 imagepair.KEY__IMAGEPAIRS__DIFFERENCES: {
50 'maxDiffPerChannel': [4, 5, 6], 50 'maxDiffPerChannel': [4, 5, 6],
51 'numDifferingPixels': 111, 51 'numDifferingPixels': 111,
52 'percentDifferingPixels': 44.444, 52 'percentDifferingPixels': 44.444,
53 'weightedDiffMeasure': 33.333, 53 'weightedDiffMeasure': 33.333,
54 }, 54 },
55 imagepair.KEY__EXPECTATIONS_DATA: { 55 imagepair.KEY__IMAGEPAIRS__EXPECTATIONS: {
56 'bugs': [1001, 1002], 56 'bugs': [1001, 1002],
57 'ignoreFailure': True, 57 'ignoreFailure': True,
58 }, 58 },
59 imagepair.KEY__EXTRA_COLUMN_VALUES: { 59 imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS: {
60 'builder': 'MyBuilder', 60 'builder': 'MyBuilder',
61 'test': 'test3', 61 'test': 'test3',
62 }, 62 },
63 imagepair.KEY__IMAGE_A_URL: 'test3/3333.png', 63 imagepair.KEY__IMAGEPAIRS__IMAGE_A_URL: 'test3/3333.png',
64 imagepair.KEY__IMAGE_B_URL: 'test3/33334.png', 64 imagepair.KEY__IMAGEPAIRS__IMAGE_B_URL: 'test3/33334.png',
65 imagepair.KEY__IS_DIFFERENT: True, 65 imagepair.KEY__IMAGEPAIRS__IS_DIFFERENT: True,
66 } 66 }
67 SET_A_DESCRIPTION = 'expectations' 67 SET_A_DESCRIPTION = 'expectations'
68 SET_B_DESCRIPTION = 'actuals' 68 SET_B_DESCRIPTION = 'actuals'
69 69
70 70
71 class ImagePairSetTest(unittest.TestCase): 71 class ImagePairSetTest(unittest.TestCase):
72 72
73 def setUp(self): 73 def setUp(self):
74 self.maxDiff = None # do not truncate diffs when tests fail 74 self.maxDiff = None # do not truncate diffs when tests fail
75 75
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 class MockImagePair(object): 159 class MockImagePair(object):
160 """Mock ImagePair object, which will return canned results.""" 160 """Mock ImagePair object, which will return canned results."""
161 def __init__(self, base_url, dict_to_return): 161 def __init__(self, base_url, dict_to_return):
162 """ 162 """
163 Args: 163 Args:
164 base_url: base_url attribute for this object 164 base_url: base_url attribute for this object
165 dict_to_return: dictionary to return from as_dict() 165 dict_to_return: dictionary to return from as_dict()
166 """ 166 """
167 self.base_url = base_url 167 self.base_url = base_url
168 self.extra_columns_dict = dict_to_return.get( 168 self.extra_columns_dict = dict_to_return.get(
169 imagepair.KEY__EXTRA_COLUMN_VALUES, None) 169 imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS, None)
170 self._dict_to_return = dict_to_return 170 self._dict_to_return = dict_to_return
171 171
172 def as_dict(self): 172 def as_dict(self):
173 return self._dict_to_return 173 return self._dict_to_return
174 174
175 175
176 def main(): 176 def main():
177 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairSetTest) 177 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairSetTest)
178 unittest.TextTestRunner(verbosity=2).run(suite) 178 unittest.TextTestRunner(verbosity=2).run(suite)
179 179
180 180
181 if __name__ == '__main__': 181 if __name__ == '__main__':
182 main() 182 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698