| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import sys | 5 import sys |
| 6 import textwrap | 6 import textwrap |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 import mock | 9 import mock |
| 10 | 10 |
| 11 from monacq.proto import metrics_pb2 | 11 from monacq.proto import metrics_pb2 |
| 12 | 12 |
| 13 from infra_libs.ts_mon import distribution | |
| 14 from infra_libs.ts_mon import errors | |
| 15 from infra_libs.ts_mon import interface | 13 from infra_libs.ts_mon import interface |
| 16 from infra_libs.ts_mon import metrics | 14 from infra_libs.ts_mon import metrics |
| 17 from infra_libs.ts_mon import targets | 15 from infra_libs.ts_mon.gae import distribution |
| 16 from infra_libs.ts_mon.gae import errors |
| 17 from infra_libs.ts_mon.gae import targets |
| 18 | 18 |
| 19 | 19 |
| 20 class FakeState(interface.State): | 20 class FakeState(interface.State): |
| 21 def __init__(self): | 21 def __init__(self): |
| 22 super(FakeState, self).__init__() | 22 super(FakeState, self).__init__() |
| 23 self.global_monitor = mock.Mock() | 23 self.global_monitor = mock.Mock() |
| 24 | 24 |
| 25 | 25 |
| 26 class MetricTestBase(unittest.TestCase): | 26 class MetricTestBase(unittest.TestCase): |
| 27 def setUp(self): | 27 def setUp(self): |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 def test_start_timestamp(self): | 606 def test_start_timestamp(self): |
| 607 t = targets.DeviceTarget('reg', 'net', 'host') | 607 t = targets.DeviceTarget('reg', 'net', 'host') |
| 608 m = metrics.CumulativeDistributionMetric( | 608 m = metrics.CumulativeDistributionMetric( |
| 609 'test', target=t, time_fn=lambda: 1234) | 609 'test', target=t, time_fn=lambda: 1234) |
| 610 m.add(1) | 610 m.add(1) |
| 611 m.add(5) | 611 m.add(5) |
| 612 m.add(25) | 612 m.add(25) |
| 613 p = metrics_pb2.MetricsCollection() | 613 p = metrics_pb2.MetricsCollection() |
| 614 m.serialize_to(p) | 614 m.serialize_to(p) |
| 615 self.assertEquals(1234000000, p.data[0].start_timestamp_us) | 615 self.assertEquals(1234000000, p.data[0].start_timestamp_us) |
| OLD | NEW |