Chromium Code Reviews| Index: dashboard/dashboard/pinpoint/handlers/quest_parser_test.py |
| diff --git a/dashboard/dashboard/pinpoint/handlers/quest_parser_test.py b/dashboard/dashboard/pinpoint/handlers/quest_parser_test.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f42fbfe75f620a4109bf1c4c285de8a42612ec43 |
| --- /dev/null |
| +++ b/dashboard/dashboard/pinpoint/handlers/quest_parser_test.py |
| @@ -0,0 +1,146 @@ |
| +# Copyright 2017 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import unittest |
| + |
| +from dashboard.pinpoint.handlers import quest_parser |
| +from dashboard.pinpoint.models import quest |
| + |
| + |
| +_MIN_RUN_TEST_ARGUMENTS = [ |
| + 'speedometer', '--pageset-repeat', '20', '--browser', 'release', |
| + '-v', '--upload-results', '--output-format', 'chartjson', |
| + '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| + '--isolated-script-test-chartjson-output', |
| + '${ISOLATED_OUTDIR}/chartjson-output.json', |
| +] |
| + |
| + |
| +_ALL_RUN_TEST_ARGUMENTS = [ |
| + 'speedometer', '--story-filter', 'http://www.fifa.com/', |
| + '--pageset-repeat', '50', '--browser', 'release', |
| + '-v', '--upload-results', '--output-format', 'chartjson', |
| + '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| + '--isolated-script-test-chartjson-output', |
| + '${ISOLATED_OUTDIR}/chartjson-output.json', |
| +] |
| + |
| + |
| +class FindIsolateTest(unittest.TestCase): |
| + |
| + def testMissingArguments(self): |
| + arguments = {'target': 'telemetry_perf_tests'} |
| + # configuration is missing. |
| + with self.assertRaises(TypeError): |
| + quest_parser.ParseQuests(arguments) |
| + |
| + arguments = {'configuration': 'chromium-rel-mac11-pro'} |
| + # target is missing. |
| + with self.assertRaises(TypeError): |
| + quest_parser.ParseQuests(arguments) |
| + |
| + def testAllArguments(self): |
| + arguments = { |
| + 'configuration': 'chromium-rel-mac11-pro', |
| + 'target': 'telemetry_perf_tests', |
| + } |
| + expected = [ |
|
perezju
2017/08/23 08:59:59
nit: expected_quests
dtu
2017/08/24 23:17:52
Done.
|
| + quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| + ] |
| + self.assertEqual(quest_parser.ParseQuests(arguments), (arguments, expected)) |
| + |
| + |
| +class TelemetryRunTestQuest(unittest.TestCase): |
| + |
| + def testMissingArguments(self): |
| + arguments = { |
| + 'configuration': 'chromium-rel-mac11-pro', |
| + 'target': 'telemetry_perf_tests', |
| + 'dimensions': '{}', |
| + # benchmark is missing. |
| + 'browser': 'release', |
| + } |
| + with self.assertRaises(TypeError): |
| + quest_parser.ParseQuests(arguments) |
| + |
| + arguments = { |
| + 'configuration': 'chromium-rel-mac11-pro', |
| + 'target': 'telemetry_perf_tests', |
| + 'dimensions': '{}', |
| + 'benchmark': 'speedometer', |
| + # browser is missing. |
| + } |
| + with self.assertRaises(TypeError): |
| + quest_parser.ParseQuests(arguments) |
| + |
| + def testMinimumArguments(self): |
| + arguments = { |
| + 'configuration': 'chromium-rel-mac11-pro', |
| + 'target': 'telemetry_perf_tests', |
| + 'dimensions': '{}', |
| + 'benchmark': 'speedometer', |
| + 'browser': 'release', |
| + } |
| + |
| + expected = [ |
| + quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| + quest.RunTest({}, _MIN_RUN_TEST_ARGUMENTS), |
| + ] |
| + self.assertEqual(quest_parser.ParseQuests(arguments), (arguments, expected)) |
| + |
| + def testAllArguments(self): |
| + arguments = { |
| + 'configuration': 'chromium-rel-mac11-pro', |
| + 'target': 'telemetry_perf_tests', |
| + 'dimensions': '{"key": "value"}', |
| + 'benchmark': 'speedometer', |
| + 'browser': 'release', |
| + 'story': 'http://www.fifa.com/', |
| + 'repeat_count': '50', |
| + } |
| + |
| + expected = [ |
| + quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| + quest.RunTest({'key': 'value'}, _ALL_RUN_TEST_ARGUMENTS), |
| + ] |
| + self.assertEqual(quest_parser.ParseQuests(arguments), (arguments, expected)) |
| + |
| + |
| +class ReadChartJsonValueQuest(unittest.TestCase): |
| + |
| + def testMinimumArguments(self): |
| + arguments = { |
| + 'configuration': 'chromium-rel-mac11-pro', |
| + 'target': 'telemetry_perf_tests', |
| + 'dimensions': '{}', |
| + 'benchmark': 'speedometer', |
| + 'browser': 'release', |
| + 'metric': 'pcv1-cold@@timeToFirst', |
| + } |
| + |
| + expected = [ |
| + quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| + quest.RunTest({}, _MIN_RUN_TEST_ARGUMENTS), |
| + quest.ReadChartJsonValue('pcv1-cold@@timeToFirst', None), |
| + ] |
| + self.assertEqual(quest_parser.ParseQuests(arguments), (arguments, expected)) |
| + |
| + def testAllArguments(self): |
| + arguments = { |
| + 'configuration': 'chromium-rel-mac11-pro', |
| + 'target': 'telemetry_perf_tests', |
| + 'dimensions': '{"key": "value"}', |
| + 'benchmark': 'speedometer', |
| + 'browser': 'release', |
| + 'story': 'http://www.fifa.com/', |
| + 'repeat_count': '50', |
| + 'metric': 'pcv1-cold@@timeTo', |
| + } |
| + |
| + expected = [ |
| + quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| + quest.RunTest({'key': 'value'}, _ALL_RUN_TEST_ARGUMENTS), |
| + quest.ReadChartJsonValue('pcv1-cold@@timeTo', 'http://www.fifa.com/'), |
| + ] |
| + self.assertEqual(quest_parser.ParseQuests(arguments), (arguments, expected)) |
|
perezju
2017/08/23 08:59:59
hmm.. so the arguments we send as input are also n
dtu
2017/08/24 23:17:52
We mostly just want them to display the configurat
|