예제 #1
0
 def test_start_manager_publisher_and_channel(self):
     publisher = metrics.MetricPublisher()
     mm = metrics.MetricManager("vumi.test.", publisher=publisher)
     self.assertEqual(mm._publisher, publisher)
     self.assertEqual(mm._task, None)
     channel = yield get_stubbed_channel(self.worker_helper.broker)
     self.assertRaises(RuntimeError, mm.start, channel)
예제 #2
0
 def test_start_manager_publisher_and_channel(self):
     publisher = metrics.MetricPublisher()
     mm = metrics.MetricManager("vumi.test.", publisher=publisher)
     self.assertEqual(mm._publisher, publisher)
     self.assertEqual(mm._task, None)
     yield self.assertFailure(self.start_manager_as_publisher(mm),
                              RuntimeError)
예제 #3
0
 def test_start_polling_with_publisher(self):
     publisher = metrics.MetricPublisher()
     mm = metrics.MetricManager("vumi.test.", publisher=publisher)
     self.assertEqual(mm._publisher, publisher)
     self.assertEqual(mm._task, None)
     mm.start_polling()
     self.add_cleanup(mm.stop_polling)
     self.assertEqual(mm._publisher, publisher)
     self.assertNotEqual(mm._task, None)
예제 #4
0
    def test_publish_single_metric(self):
        publisher = metrics.MetricPublisher()
        yield self.start_publisher(publisher)

        msg = metrics.MetricMessage()
        cnt = metrics.Count("my.count")
        msg.append(
            ("vumi.test.%s" % (cnt.name,), cnt.aggs, [(time.time(), 1)]))
        publisher.publish_message(msg)
        self._check_msg("vumi.test.", cnt, [1])
예제 #5
0
 def test_publisher_provides_interface(self):
     publisher = metrics.MetricPublisher()
     self.assertTrue(metrics.IMetricPublisher.providedBy(publisher))