Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Unit tests for upload_test_results.py.""" | 6 """Unit tests for upload_test_results.py.""" |
| 7 | 7 |
| 8 import json | 8 import json |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 result_directory = tempfile.mkdtemp() | 143 result_directory = tempfile.mkdtemp() |
| 144 try: | 144 try: |
| 145 input_json_file_path = os.path.join(result_directory, 'results.json') | 145 input_json_file_path = os.path.join(result_directory, 'results.json') |
| 146 with open(input_json_file_path, 'w') as f: | 146 with open(input_json_file_path, 'w') as f: |
| 147 json.dump(contents, f) | 147 json.dump(contents, f) |
| 148 upload_test_results.main([ | 148 upload_test_results.main([ |
| 149 '--test-type=foo', | 149 '--test-type=foo', |
| 150 '--input-json=%s' % input_json_file_path, | 150 '--input-json=%s' % input_json_file_path, |
| 151 '--results-directory=%s' % result_directory, | 151 '--results-directory=%s' % result_directory, |
| 152 '--test-results-server=foo', | 152 '--test-results-server=foo', |
| 153 '--builder-name=hobbit', | |
| 154 '--build-number=1234', | |
| 155 '--chrome-revision=99999', | |
| 153 '--master-name=sauron', | 156 '--master-name=sauron', |
| 154 ]) | 157 ]) |
| 155 files = [(os.path.basename(input_json_file_path), input_json_file_path)] | 158 uploaded_json_result_path = os.path.join( |
|
nednguyen
2016/11/11 00:53:15
I notice that this wasn't updated when you uploade
estaab
2016/11/11 04:57:31
Ah, thanks for fixing this.
| |
| 159 result_directory, upload_test_results.FULL_RESULTS_FILENAME) | |
| 160 | |
| 161 # Assert that metadata are added to the json results before uploading. | |
| 162 with open(uploaded_json_result_path) as f: | |
| 163 augmented_json = json.load(f) | |
| 164 self.assertEquals(augmented_json.get('master_name'), 'sauron') | |
| 165 self.assertEquals(augmented_json.get('builder_name'), 'hobbit') | |
| 166 self.assertEquals(augmented_json.get('build_number'), '1234') | |
| 167 self.assertEquals(augmented_json.get('chromium_revision'), '99999') | |
| 168 | |
| 169 files = [('full_results.json', uploaded_json_result_path)] | |
| 156 uploader_mock.assert_called_with( | 170 uploader_mock.assert_called_with( |
| 157 'foo', | 171 'foo', |
| 158 [('builder', 'DUMMY_BUILDER_NAME'), | 172 [('builder', 'hobbit'), |
| 159 ('testtype', 'foo'), | 173 ('testtype', 'foo'), |
| 160 ('master', 'sauron')], files, 120) | 174 ('master', 'sauron')], files, 120) |
| 161 finally: | 175 finally: |
| 162 shutil.rmtree(result_directory) | 176 shutil.rmtree(result_directory) |
| 163 | 177 |
| 164 | 178 |
| 165 | |
| 166 if __name__ == '__main__': | 179 if __name__ == '__main__': |
| 167 unittest.main() | 180 unittest.main() |
| OLD | NEW |