def test_set_one_metric_with_start_time(self): json_str = '{"name": "test/name", "value": 13, "start_time": 1234}' metric = common.set_metric(json_str, ts_mon.CounterMetric) self.assertIsInstance(metric, ts_mon.CounterMetric) self.assertTrue(metric._name.startswith("test/name")) self.assertEquals(metric._start_time, 1234) ts_mon.unregister(metric) # Cleanup
def test_set_multiple_metrics(self): # list of json strs, call set_metrics json_strs = ['{"name": "test/name1", "value": 13}', '{"name": "test/name2", "value": 14}'] metrics = common.set_metrics(json_strs, ts_mon.GaugeMetric) self.assertEquals(len(metrics), len(json_strs)) for metric in metrics: self.assertIsInstance(metric, ts_mon.GaugeMetric) # TODO(pgervais): Add a property to ts_mon.Metric instead. self.assertTrue(metric._name.startswith("test/name")) ts_mon.unregister(metric) # Cleanup
def test_set_one_metric(self): json_str = '{"name": "test/name", "value": 13}' metric = common.set_metric(json_str, ts_mon.GaugeMetric) self.assertIsInstance(metric, ts_mon.GaugeMetric) ts_mon.unregister(metric) # Cleanup