def test_set_one_file(self): metrics = common.set_metrics_file( [os.path.join(DATA_DIR, 'one_json_line.txt')], ts_mon.GaugeMetric) print metrics self.assertEqual(1, len(metrics)) self.assertIsInstance(metrics[0], ts_mon.GaugeMetric)
def test_base64_encoding(self): metrics = common.set_metrics_file( [os.path.join(DATA_DIR, 'two_base64_lines.txt')], ts_mon.GaugeMetric) self.assertEqual(2, len(metrics)) for metric in metrics: self.assertIsInstance(metric, ts_mon.GaugeMetric) # Make sure we get the two names we're supposed to get names = set(metric.name for metric in metrics) self.assertEqual(2, len(names)) for name in names: self.assertTrue(name.startswith('json_line_'))
def test_set_two_files(self): metrics = common.set_metrics_file([ os.path.join(DATA_DIR, 'one_json_line.txt'), os.path.join(DATA_DIR, 'two_json_lines.txt') ], ts_mon.GaugeMetric) self.assertEqual(3, len(metrics)) for metric in metrics: self.assertIsInstance(metric, ts_mon.GaugeMetric) # Make sure we get all the names we're supposed to get names = set(metric.name for metric in metrics) self.assertEqual(3, len(names)) for name in names: self.assertTrue(name.startswith('json_line_'))
def test_set_two_files(self): metrics = common.set_metrics_file( [os.path.join(DATA_DIR, 'one_json_line.txt'), os.path.join(DATA_DIR, 'two_json_lines.txt')], ts_mon.GaugeMetric) self.assertEqual(3, len(metrics)) for metric in metrics: self.assertIsInstance(metric, ts_mon.GaugeMetric) # Make sure we get all the names we're supposed to get names = set(metric.name for metric in metrics) self.assertEqual(3, len(names)) for name in names: self.assertTrue(name.startswith('json_line_'))
def test_set_no_file(self): metrics = common.set_metrics_file([], ts_mon.GaugeMetric) self.assertEqual(0, len(metrics))