| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 import json |
| 5 import os |
| 6 import tempfile |
| 7 import unittest |
| 8 |
| 9 from telemetry.internal.results import valueset_output_formatter |
| 10 from telemetry.internal.results import page_test_results |
| 11 |
| 12 |
| 13 class ValueSetOutputFormatterTest(unittest.TestCase): |
| 14 |
| 15 def setUp(self): |
| 16 self.output_file_path = tempfile.mkstemp()[1] |
| 17 |
| 18 def tearDown(self): |
| 19 try: |
| 20 os.remove(self.output_file_path) |
| 21 except OSError: |
| 22 pass |
| 23 |
| 24 def test_basic_summary(self): |
| 25 sample = { |
| 26 'name': 'a', |
| 27 'guid': '42', |
| 28 'description': 'desc', |
| 29 'important': False, |
| 30 'diagnostics': [], |
| 31 'type': 'numeric', |
| 32 'numeric': { |
| 33 'unit': 'n%', |
| 34 'type': 'scalar', |
| 35 'value': 42 |
| 36 } |
| 37 } |
| 38 |
| 39 results = page_test_results.PageTestResults() |
| 40 results.value_set.extend([sample]) |
| 41 |
| 42 with open(self.output_file_path, 'w') as output_file: |
| 43 formatter = valueset_output_formatter.ValueSetOutputFormatter(output_file) |
| 44 formatter.Format(results) |
| 45 |
| 46 written_data = json.load(open(self.output_file_path)) |
| 47 self.assertEqual([sample], written_data) |
| 48 |
| OLD | NEW |