Chromium Code Reviews| Index: scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py |
| diff --git a/scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py b/scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py |
| index 1b62f377872d26b2fa14072da3cf7c92179f869a..7ca8855380caf94bb07429befeed0dd5bcf3c2f9 100755 |
| --- a/scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py |
| +++ b/scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py |
| @@ -79,7 +79,7 @@ class UploadTestResultsTest(unittest.TestCase): |
| results['Skipped.Test'][0].modifier) |
| @mock.patch('test_results_uploader.upload_test_results') |
| - def test_main(self, uploader_mock): |
| + def test_main_gtest_json(self, uploader_mock): |
| contents = { |
| 'per_iteration_data': [{ |
| 'Fake.Test': [ |
| @@ -114,6 +114,54 @@ class UploadTestResultsTest(unittest.TestCase): |
| finally: |
| shutil.rmtree(result_directory) |
| + @mock.patch('test_results_uploader.upload_test_results') |
| + def test_main_full_results_json(self, uploader_mock): |
| + contents = { |
| + 'tests': { |
| + 'mojom_tests': { |
| + 'parse': { |
| + 'ast_unittest': { |
| + 'ASTTest': { |
| + 'testNodeBase': { |
| + 'expected': 'PASS', |
| + 'actual': 'PASS' |
| + } |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + 'interrupted': False, |
| + 'path_delimiter': '.', |
| + 'version': 3, |
| + 'seconds_since_epoch': 1406662283.764424, |
| + 'num_failures_by_type': { |
| + 'FAIL': 0, |
| + 'PASS': 1 |
| + } |
| + } |
| + result_directory = tempfile.mkdtemp() |
| + input_json_file_path = os.path.join(result_directory, 'results.json') |
| + with open(input_json_file_path, 'w') as f: |
| + json.dump(contents, f) |
| + try: |
|
Paweł Hajdan Jr.
2016/11/07 08:30:27
nit: Since "finally" removes the directory, should
nednguyen
2016/11/07 14:26:24
Done.
|
| + upload_test_results.main([ |
| + '--test-type=foo', |
| + '--input-json=%s' % input_json_file_path, |
| + '--results-directory=%s' % result_directory, |
| + '--test-results-server=foo', |
| + '--master-name=sauron', |
| + ]) |
| + files = [(os.path.basename(input_json_file_path), input_json_file_path)] |
| + uploader_mock.assert_called_with( |
| + 'foo', |
| + [('builder', 'DUMMY_BUILDER_NAME'), |
| + ('testtype', 'foo'), |
| + ('master', 'sauron')], files, 120) |
| + finally: |
| + shutil.rmtree(result_directory) |
| + |
| + |
| if __name__ == '__main__': |
| unittest.main() |