Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: infra_libs/ts_mon/common/test/metrics_test.py

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: add noncululativedistribution metric to ts_mon imports Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 try:
12 12 from infra_libs.ts_mon import interface
13 from infra_libs.ts_mon import distribution 13 from infra_libs.ts_mon.common import metrics
14 from infra_libs.ts_mon import errors 14 from infra_libs.ts_mon.common import distribution
15 from infra_libs.ts_mon import interface 15 from infra_libs.ts_mon.common import errors
16 from infra_libs.ts_mon import metrics 16 from infra_libs.ts_mon.common import targets
17 from infra_libs.ts_mon import targets 17 from monacq.proto import metrics_pb2
18 except ImportError: # pragma: no cover
19 import interface
20 from common import metrics
21 from common import distribution
22 from common import errors
23 from common import targets
24 from monacq.proto import metrics_pb2
18 25
19 26
20 class FakeState(interface.State): 27 class FakeState(interface.State):
21 def __init__(self): 28 def __init__(self):
22 super(FakeState, self).__init__() 29 super(FakeState, self).__init__()
23 self.global_monitor = mock.Mock() 30 self.global_monitor = mock.Mock()
24 31
25 32
26 class MetricTestBase(unittest.TestCase): 33 class MetricTestBase(unittest.TestCase):
27 def setUp(self): 34 def setUp(self):
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 def test_start_timestamp(self): 613 def test_start_timestamp(self):
607 t = targets.DeviceTarget('reg', 'net', 'host') 614 t = targets.DeviceTarget('reg', 'net', 'host')
608 m = metrics.CumulativeDistributionMetric( 615 m = metrics.CumulativeDistributionMetric(
609 'test', target=t, time_fn=lambda: 1234) 616 'test', target=t, time_fn=lambda: 1234)
610 m.add(1) 617 m.add(1)
611 m.add(5) 618 m.add(5)
612 m.add(25) 619 m.add(25)
613 p = metrics_pb2.MetricsCollection() 620 p = metrics_pb2.MetricsCollection()
614 m.serialize_to(p) 621 m.serialize_to(p)
615 self.assertEquals(1234000000, p.data[0].start_timestamp_us) 622 self.assertEquals(1234000000, p.data[0].start_timestamp_us)
OLDNEW
« no previous file with comments | « infra_libs/ts_mon/common/test/helpers_test.py ('k') | infra_libs/ts_mon/common/test/standard_metrics_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698