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

Side by Side Diff: scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py

Issue 2494883003: Add metadata to json results before uploading (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « scripts/slave/recipe_modules/test_results/resources/upload_test_results.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 # 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
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()
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/test_results/resources/upload_test_results.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698