OLD | NEW |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 app = webapp2.WSGIApplication(self.APP_MAIN_MODULE.routes) | 55 app = webapp2.WSGIApplication(self.APP_MAIN_MODULE.routes) |
56 self.testapp = webtest.TestApp(app) | 56 self.testapp = webtest.TestApp(app) |
57 self.tb = testbed.Testbed() | 57 self.tb = testbed.Testbed() |
58 self.tb.activate() | 58 self.tb.activate() |
59 self.tb.init_datastore_v3_stub() | 59 self.tb.init_datastore_v3_stub() |
60 self.tb.init_blobstore_stub() | 60 self.tb.init_blobstore_stub() |
61 | 61 |
62 def tearDown(self): | 62 def tearDown(self): |
63 self.tb.deactivate() | 63 self.tb.deactivate() |
64 | 64 |
| 65 def test_basic_upload(self): |
| 66 master = master_config.getMaster('chromium.chromiumos') |
| 67 builder = 'test-builder' |
| 68 test_type = 'test-type' |
| 69 test_data = { |
| 70 'tests': { |
| 71 'Test1.testproc1': { |
| 72 'expected': 'PASS', |
| 73 'actual': 'PASS', |
| 74 'time': 1, |
| 75 } |
| 76 }, |
| 77 'build_number': '123', |
| 78 'version': JSON_RESULTS_HIERARCHICAL_VERSION, |
| 79 'builder_name': builder, |
| 80 'blink_revision': '12345', |
| 81 'seconds_since_epoch': 1406123456, |
| 82 'num_failures_by_type': { |
| 83 'FAIL': 0, |
| 84 'SKIP': 0, |
| 85 'PASS': 1 |
| 86 }, |
| 87 'chromium_revision': '67890', |
| 88 } |
| 89 |
| 90 params = collections.OrderedDict([ |
| 91 (testfilehandler.PARAM_BUILDER, builder), |
| 92 (testfilehandler.PARAM_MASTER, master['url_name']), |
| 93 (testfilehandler.PARAM_TEST_TYPE, test_type), |
| 94 ]) |
| 95 upload_files = [('file', 'full_results.json', json.JSONEncoder().encode(
test_data))] |
| 96 response = self.testapp.post('/testfile/upload', params=params, upload_f
iles=upload_files) |
| 97 self.assertEqual(response.status_int, 200) |
| 98 |
| 99 params = collections.OrderedDict([ |
| 100 (testfilehandler.PARAM_BUILDER, builder), |
| 101 (testfilehandler.PARAM_MASTER, master['url_name']), |
| 102 (testfilehandler.PARAM_TEST_TYPE, test_type), |
| 103 (testfilehandler.PARAM_BUILD_NUMBER, '123'), |
| 104 (testfilehandler.PARAM_NAME, 'full_results.json') |
| 105 ]) |
| 106 response = self.testapp.get('/testfile', params=params) |
| 107 self.assertEqual(response.status_int, 200) |
| 108 response_json = json.loads(response.normal_body) |
| 109 self.assertEqual(response_json['chromium_revision'], '67890') |
| 110 |
65 def test_deprecated_master_name(self): | 111 def test_deprecated_master_name(self): |
66 """Verify that a file uploaded with a deprecated master name | 112 """Verify that a file uploaded with a deprecated master name |
67 can be downloaded by the corresponding new-style master name. | 113 can be downloaded by the corresponding new-style master name. |
68 """ | 114 """ |
69 master = master_config.getMaster('chromium.chromiumos') | 115 master = master_config.getMaster('chromium.chromiumos') |
70 builder = 'test-builder' | 116 builder = 'test-builder' |
71 test_type = 'test-type' | 117 test_type = 'test-type' |
72 test_data = { | 118 test_data = { |
73 'tests': { | 119 'tests': { |
74 'Test1.testproc1': { | 120 'Test1.testproc1': { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 (testfilehandler.PARAM_NAME, 'full_results.json') | 168 (testfilehandler.PARAM_NAME, 'full_results.json') |
123 ]) | 169 ]) |
124 response = self.testapp.get('/testfile', params=params) | 170 response = self.testapp.get('/testfile', params=params) |
125 self.assertEqual(response.status_int, 200) | 171 self.assertEqual(response.status_int, 200) |
126 response_json = json.loads(response.normal_body) | 172 response_json = json.loads(response.normal_body) |
127 self.assertEqual(response_json['chromium_revision'], '67890') | 173 self.assertEqual(response_json['chromium_revision'], '67890') |
128 | 174 |
129 if __name__ == '__main__': | 175 if __name__ == '__main__': |
130 logging.basicConfig(level=logging.ERROR) | 176 logging.basicConfig(level=logging.ERROR) |
131 unittest.main() | 177 unittest.main() |
OLD | NEW |