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

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

Issue 2114073002: Add HttpsMonitor (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Add HttpsMonitor Created 4 years, 5 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import unittest
6
7 from infra_libs.ts_mon.common import monitors
8 from infra_libs.ts_mon.common import pb_to_popo
9 from infra_libs.ts_mon.protos import acquisition_network_device_pb2
10 from infra_libs.ts_mon.protos import acquisition_task_pb2
11 from infra_libs.ts_mon.protos import metrics_pb2
12
13 class PbToPopoTest(unittest.TestCase):
14
15 def test_convert(self):
16 task = acquisition_task_pb2.Task(service_name='service')
17 network_device = acquisition_network_device_pb2.NetworkDevice(
18 hostname='host', alertable=True)
19 metric1 = metrics_pb2.MetricsData(name='m1', counter=200, task=task,
20 units=metrics_pb2.MetricsData.Units.Value('SECONDS'))
21 metric2 = metrics_pb2.MetricsData(name='m2', network_device=network_device,
22 cumulative_double_value=123.456)
23 collection = metrics_pb2.MetricsCollection(data=[metric1, metric2],
24 start_timestamp_us=12345)
25
26 popo = pb_to_popo.convert(collection)
27 expected = {
28 'data': [
29 {
30 'name': 'm1',
31 'counter': 200L,
32 'task': { 'service_name': 'service' },
33 'units': 1
34 },
35 {
36 'name': 'm2',
37 'cumulative_double_value': 123.456,
38 'network_device': { 'hostname': 'host', 'alertable': True }
39 }
40 ],
41 'start_timestamp_us': 12345L
42 }
43 self.assertDictEqual(expected, popo)
44
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698