def testCreateJsonTestResultBasic(self): retval = result_sink._create_json_test_result( 'test_id', json_results.ResultType.Pass, True, {'artifact': {'filePath': 'somepath'}}, [('tag_key', 'tag_value')], '<pre>summary</pre>', 1, {'name': 'test_name', 'location': {'repo': 'a repo'}}) self.assertEqual(retval, { 'testId': 'test_id', 'status': json_results.ResultType.Pass, 'expected': True, 'duration': '1.000000000s', 'summaryHtml': '<pre>summary</pre>', 'artifacts': { 'artifact': { 'filePath': 'somepath', }, }, 'tags': [ { 'key': 'tag_key', 'value': 'tag_value', }, ], 'testMetadata': { 'name': 'test_name', 'location': { 'repo': 'a repo', }, }, })
def testCreateJsonFormatsWithVeryLongDuration(self): retval = result_sink._create_json_test_result( 'test_id', json_results.ResultType.Pass, True, {'artifact': { 'filePath': 'somepath' }}, [('tag_key', 'tag_value')], '<pre>summary</pre>', 1e+16) self.assertEqual(retval['duration'], '10000000000000000.000000000s')
def testCreateJsonTestResultInvalidSummary(self): with self.assertRaises(AssertionError): result_sink._create_json_test_result( 'test_id', json_results.ResultType.Pass, True, {}, {}, 'a' * 4097, 1, {})
def testCreateJsonTestResultInvalidStatus(self): with self.assertRaises(AssertionError): result_sink._create_json_test_result( 'test_id', 'InvalidStatus', False, {}, {}, '', 1, {})