def test_metric_getter(self):
     mr = BaseMetricsReporter()
     mr.start()
     # increment a counter
     mr.registry[0].counter('test').inc()
     timestamp, metrics = mr.get_metrics()
     self.assertIsInstance(timestamp, integer_types)
     self.assertIsInstance(metrics, dict)
     self.assertEqual(len(metrics), 1)
     self.assertIn('test', metrics)
     self.assertIsInstance(metrics['test'], dict)
     self.assertEqual(metrics['test']['count'], 1)
     mr.stop()
 def test_metric_sender(self):
     mr = BaseMetricsReporter()
     mr.start()
     mr.registry[0].counter('test').inc()
     mr.send_metrics()
 def test_start_stop_mechanism(self):
     mr = BaseMetricsReporter()
     mr.start()
     self.assertTrue(mr.task.running)
     mr.stop()
     self.assertFalse(mr.task.running)