Пример #1
0
    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)
Пример #2
0
 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)
Пример #3
0
  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)
Пример #4
0
  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)
Пример #5
0
  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)
Пример #6
0
    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')
Пример #7
0
  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))
Пример #9
0
  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()
Пример #10
0
  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)
Пример #11
0
    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)
Пример #13
0
 def testAllArguments(self):
   quest = read_value.ReadGraphJsonValue.FromDict(_BASE_ARGUMENTS_GRAPH_JSON)
   expected = read_value.ReadGraphJsonValue('chart_name', 'trace_name')
   self.assertEqual(quest, expected)
Пример #14
0
 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)
Пример #15
0
 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)