def testUploadArtifacts(self): test_result = testing.TestResult( 'benchmark/story', output_artifacts={ 'logs': testing.Artifact('/log.log'), 'trace.html': testing.Artifact('/trace.html'), 'screenshot': testing.Artifact('/screenshot.png'), }, ) with mock.patch('py_utils.cloud_storage.Insert') as cloud_patch: cloud_patch.return_value = 'gs://url' processor.UploadArtifacts(test_result, 'bucket', 'run1') cloud_patch.assert_has_calls( [ mock.call('bucket', 'run1/benchmark/story/logs', '/log.log'), mock.call('bucket', 'run1/benchmark/story/trace.html', '/trace.html'), mock.call('bucket', 'run1/benchmark/story/screenshot', '/screenshot.png'), ], any_order=True, ) for artifact in test_result['outputArtifacts'].itervalues(): self.assertEqual(artifact['remoteUrl'], 'gs://url')
def testUploadArtifacts(self): test_result = testing.TestResult( 'benchmark/story', output_artifacts={ 'logs': testing.Artifact('/log.log'), 'trace.html': testing.Artifact('/trace.html'), 'screenshot': testing.Artifact('/screenshot.png'), }, ) with mock.patch('py_utils.cloud_storage.Upload') as cloud_patch: cloud_patch.return_value = processor.cloud_storage.CloudFilepath( 'bucket', 'path') processor.UploadArtifacts(test_result, 'bucket', 'run1') cloud_patch.assert_has_calls( [ mock.call('bucket', 'run1/benchmark/story/retry_0/logs', '/log.log'), mock.call('bucket', 'run1/benchmark/story/retry_0/trace.html', '/trace.html'), mock.call('bucket', 'run1/benchmark/story/retry_0/screenshot', '/screenshot.png'), ], any_order=True, ) for artifact in test_result['outputArtifacts'].values(): self.assertEqual(artifact['fetchUrl'], 'gs://bucket/path') self.assertEqual( artifact['viewUrl'], 'https://console.developers.google.com' '/m/cloudstorage/b/bucket/o/path')
def testUploadArtifacts(self): in_results = testing.IntermediateResults(test_results=[ testing.TestResult( 'benchmark/story', output_artifacts={'log': testing.Artifact('/log.log')}, ), testing.TestResult( 'benchmark/story', output_artifacts={ 'trace.html': testing.Artifact('/trace.html'), 'screenshot': testing.Artifact('/screenshot.png'), }, ), ], ) with mock.patch('py_utils.cloud_storage.Insert') as cloud_patch: cloud_patch.return_value = 'gs://url' processor.UploadArtifacts(in_results, 'bucket', None) cloud_patch.assert_has_calls( [ mock.call('bucket', mock.ANY, '/log.log'), mock.call('bucket', mock.ANY, '/trace.html'), mock.call('bucket', mock.ANY, '/screenshot.png'), ], any_order=True, ) for result in in_results['testResults']: for artifact in result['outputArtifacts'].itervalues(): self.assertEqual(artifact['remoteUrl'], 'gs://url')
def testUploadArtifacts_CheckRemoteUrl(self): in_results = testing.IntermediateResults( test_results=[ testing.TestResult( 'benchmark/story', output_artifacts={ 'trace.html': testing.Artifact('/trace.html') }, ), ], start_time='2019-10-01T12:00:00.123456Z', ) with mock.patch('py_utils.cloud_storage.Insert') as cloud_patch: with mock.patch('random.randint') as randint_patch: randint_patch.return_value = 54321 processor.UploadArtifacts(in_results, 'bucket', 'src@abc + 123') cloud_patch.assert_called_once_with( 'bucket', 'src_abc_123_20191001T120000_54321/benchmark/story/trace.html', '/trace.html')