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

Side by Side Diff: Tools/TestResultServer/handlers/testfilehandler_test.py

Issue 459243004: Fix 500 in test results server when querying testlistjson (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « Tools/TestResultServer/handlers/testfilehandler.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import collections 7 import collections
8 import json 8 import json
9 import imp 9 import imp
10 import logging 10 import logging
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 {'results': [[1, 'Q']], 'times': [[1, 1]]}) 110 {'results': [[1, 'Q']], 'times': [[1, 1]]})
111 111
112 # test testlistjson=1 112 # test testlistjson=1
113 params[testfilehandler.PARAM_TEST_LIST_JSON] = '1' 113 params[testfilehandler.PARAM_TEST_LIST_JSON] = '1'
114 114
115 response = self.testapp.get('/testfile', params=params) 115 response = self.testapp.get('/testfile', params=params)
116 self.assertEqual(response.status_int, 200) 116 self.assertEqual(response.status_int, 200)
117 response_json = json.loads(response.normal_body) 117 response_json = json.loads(response.normal_body)
118 self.assertEqual(response_json[builder]['tests']['Test1.testproc1'], {}) 118 self.assertEqual(response_json[builder]['tests']['Test1.testproc1'], {})
119 119
120 def test_get_nonexistant_results(self):
121 master = master_config.getMaster('chromium.chromiumos')
122 builder = 'test-builder'
123 test_type = 'test-type'
124
125 params = collections.OrderedDict([
126 (testfilehandler.PARAM_BUILDER, builder),
127 (testfilehandler.PARAM_MASTER, master['url_name']),
128 (testfilehandler.PARAM_TEST_TYPE, test_type),
129 (testfilehandler.PARAM_NAME, 'results.json')
130 ])
131
132 try:
133 response = self.testapp.get('/testfile', params=params)
134 except webtest.app.AppError as e:
135 # FIXME: Is there a better way to check for a 404?
136 self.assertIn('404', e.message)
137
138 params[testfilehandler.PARAM_TEST_LIST_JSON] = '1'
139
140 try:
141 response = self.testapp.get('/testfile', params=params)
142 except webtest.app.AppError as e:
143 # FIXME: Is there a better way to check for a 404?
144 self.assertIn('404', e.message)
145
120 def test_deprecated_master_name(self): 146 def test_deprecated_master_name(self):
121 """Verify that a file uploaded with a deprecated master name 147 """Verify that a file uploaded with a deprecated master name
122 can be downloaded by the corresponding new-style master name. 148 can be downloaded by the corresponding new-style master name.
123 """ 149 """
124 master = master_config.getMaster('chromium.chromiumos') 150 master = master_config.getMaster('chromium.chromiumos')
125 builder = 'test-builder' 151 builder = 'test-builder'
126 test_type = 'test-type' 152 test_type = 'test-type'
127 test_data = { 153 test_data = {
128 'tests': { 154 'tests': {
129 'Test1.testproc1': { 155 'Test1.testproc1': {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 (testfilehandler.PARAM_NAME, 'full_results.json') 203 (testfilehandler.PARAM_NAME, 'full_results.json')
178 ]) 204 ])
179 response = self.testapp.get('/testfile', params=params) 205 response = self.testapp.get('/testfile', params=params)
180 self.assertEqual(response.status_int, 200) 206 self.assertEqual(response.status_int, 200)
181 response_json = json.loads(response.normal_body) 207 response_json = json.loads(response.normal_body)
182 self.assertEqual(response_json['chromium_revision'], '67890') 208 self.assertEqual(response_json['chromium_revision'], '67890')
183 209
184 if __name__ == '__main__': 210 if __name__ == '__main__':
185 logging.basicConfig(level=logging.ERROR) 211 logging.basicConfig(level=logging.ERROR)
186 unittest.main() 212 unittest.main()
OLDNEW
« no previous file with comments | « Tools/TestResultServer/handlers/testfilehandler.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698