def testReadGraphJsonValue(self, retrieve): retrieve.side_effect = ( { 'files': { 'chartjson-output.json': { 'h': 'graphjson hash' } } }, json.dumps( {'chart': { 'traces': { 'trace': ['126444.869721', '0.0'] } }}), ) quest = read_value.ReadGraphJsonValue('chart', 'trace') execution = quest.Start(('output hash', )) execution.Poll() self.assertTrue(execution.completed) self.assertFalse(execution.failed) self.assertEqual(execution.result_values, (126444.869721, )) self.assertEqual(execution.result_arguments, {}) expected_calls = [ mock.call('output hash'), mock.call('graphjson hash') ] self.assertEqual(retrieve.mock_calls, expected_calls)
def testMissingTrace(self): arguments = dict(_BASE_ARGUMENTS_GRAPH_JSON) del arguments['trace'] quest = read_value.ReadGraphJsonValue.FromDict(arguments) expected = read_value.ReadGraphJsonValue( 'base_perftests/perf_results.json', 'chart_name', None) self.assertEqual(quest, expected)
def testReadGraphJsonValueWithMissingTrace(self): self.SetOutputFileContents({'chart': {'traces': {}}}) quest = read_value.ReadGraphJsonValue('metric', 'test') execution = quest.Start(None, 'server', 'output hash') execution.Poll() self.assertReadValueError(execution)
def testReadGraphJsonValueWithMissingFile(self): self._retrieve.return_value = '{"files": {}}' quest = read_value.ReadGraphJsonValue('metric', 'test') execution = quest.Start(None, 'server', 'output hash') execution.Poll() self.assertReadValueError(execution)
def testReadGraphJsonValueWithMissingFile(self, retrieve): retrieve.return_value = {'files': {}} quest = read_value.ReadGraphJsonValue('metric', 'test') execution = quest.Start(None, 'output hash') execution.Poll() self.assertReadValueError(execution)
def testReadGraphJsonValueWithMissingChart(self): self.SetOutputFileContents({}) quest = read_value.ReadGraphJsonValue('chartjson-output.json', 'metric', 'test') execution = quest.Start(None, 'server', 'output hash') execution.Poll() self.assertReadValueError(execution, 'ReadValueChartNotFound')
def testReadGraphJsonValueWithMissingChart(self): self.SetOutputFileContents({}) quest = read_value.ReadGraphJsonValue( 'base_perftests/perf_results.json', 'metric', 'test') execution = quest.Start(None, 'server', 'output hash') execution.Poll() self.assertReadValueError(execution)
def testAllArguments(self): arguments = { 'chart': 'chart_name', 'trace': 'trace_name', } expected = read_value.ReadGraphJsonValue('chart_name', 'trace_name') self.assertEqual(read_value.ReadGraphJsonValue.FromDict(arguments), (arguments, expected))
def testReadGraphJsonValue(self): self.SetOutputFileContents( {'chart': {'traces': {'trace': ['126444.869721', '0.0']}}}) quest = read_value.ReadGraphJsonValue('chart', 'trace') execution = quest.Start(None, 'server', 'output hash') execution.Poll() self.assertReadValueSuccess(execution) self.assertEqual(execution.result_values, (126444.869721,)) self.assertRetrievedOutputJson()
def testReadGraphJsonValueWithMissingTrace(self, retrieve): retrieve.side_effect = ( {'files': {'chartjson-output.json': {'h': 'graphjson hash'}}}, json.dumps({'chart': {'traces': {}}}), ) quest = read_value.ReadGraphJsonValue('metric', 'test') execution = quest.Start(None, 'output hash') execution.Poll() self.assertReadValueError(execution)
def testReadGraphJsonValue_PerformanceBrowserTests(self): contents = {'chart': {'traces': {'trace': ['126444.869721', '0.0']}}} self._retrieve.side_effect = ( '{"files": {"browser_tests/perf_results.json": {"h": "foo"}}}', json.dumps(contents), ) quest = read_value.ReadGraphJsonValue( 'performance_browser_tests/perf_results.json', 'chart', 'trace') execution = quest.Start(None, 'server', 'output hash') execution.Poll() self.assertReadValueSuccess(execution) self.assertEqual(execution.result_values, (126444.869721, )) expected_calls = [ mock.call('server', 'output hash'), mock.call('server', 'foo'), ] self.assertEqual(self._retrieve.mock_calls, expected_calls)
def testReadGraphJsonValue(self): self.SetOutputFileContents( {'chart': { 'traces': { 'trace': ['126444.869721', '0.0'] } }}) quest = read_value.ReadGraphJsonValue('chart', 'trace') execution = quest.Start(None, 'output hash') execution.Poll() self.assertTrue(execution.completed) self.assertFalse(execution.failed) self.assertEqual(execution.result_values, (126444.869721, )) self.assertEqual(execution.result_arguments, {}) expected_calls = [ mock.call('output hash'), mock.call('output json hash') ] self.assertEqual(self._retrieve.mock_calls, expected_calls)
def testAllArguments(self): quest = read_value.ReadGraphJsonValue.FromDict(_BASE_ARGUMENTS_GRAPH_JSON) expected = read_value.ReadGraphJsonValue('chart_name', 'trace_name') self.assertEqual(quest, expected)
def testMinimumArguments(self): quest = read_value.ReadGraphJsonValue.FromDict( _BASE_ARGUMENTS_GRAPH_JSON) expected = read_value.ReadGraphJsonValue( 'base_perftests/perf_results.json', 'chart_name', 'trace_name') self.assertEqual(quest, expected)
def testMissingChart(self): arguments = dict(_BASE_ARGUMENTS_GRAPH_JSON) del arguments['chart'] quest = read_value.ReadGraphJsonValue.FromDict(arguments) expected = read_value.ReadGraphJsonValue(None, 'trace_name') self.assertEqual(quest, expected)