Пример #1
0
 def test_poll(self):
     metric = metrics.Metric("foo")
     metric.manage("prefix.")
     self.check_poll(metric, [])
     metric.set(1.0)
     metric.set(2.0)
     self.check_poll(metric, [1.0, 2.0])
Пример #2
0
 def test_manage(self):
     metric = metrics.Metric("foo")
     self.assertEqual(metric.name, None)
     metric.manage("vumi.test.")
     self.assertEqual(metric.name, "vumi.test.foo")
     self.assertRaises(metrics.MetricRegistrationError, metric.manage,
                       "vumi.othertest.")
Пример #3
0
 def test_manage(self):
     mm = metrics.MetricManager("vumi.test.")
     metric = metrics.Metric("foo")
     metric.manage(mm)
     self.assertEqual(metric.name, "foo")
     mm2 = metrics.MetricManager("vumi.othertest.")
     self.assertRaises(metrics.MetricRegistrationError, metric.manage, mm2)
Пример #4
0
    def test_in_worker(self):
        worker = yield self.worker_helper.get_worker(Worker, {}, start=False)
        mm = yield worker.start_publisher(metrics.MetricManager,
                                          "vumi.test.", 0.1, self.on_publish)
        acc = mm.register(metrics.Metric("my.acc"))
        try:
            self.assertTrue(mm._task is not None)
            self._check_msg(mm, acc, None)

            acc.set(1.5)
            acc.set(1.0)
            yield self.wait_publish()
            self._check_msg(mm, acc, [1.5, 1.0])
        finally:
            mm.stop()
Пример #5
0
    def test_in_worker(self):
        worker = get_stubbed_worker(Worker)
        broker = worker._amqp_client.broker
        mm = yield worker.start_publisher(metrics.MetricManager, "vumi.test.",
                                          0.1, self.on_publish)
        acc = mm.register(metrics.Metric("my.acc"))
        try:
            self.assertTrue(mm._task is not None)
            self._check_msg(broker, acc, None)

            acc.set(1.5)
            acc.set(1.0)
            yield self.wait_publish()
            self._check_msg(broker, acc, [1.5, 1.0])
        finally:
            mm.stop()
Пример #6
0
 def test_managed(self):
     metric = metrics.Metric("foo")
     self.assertFalse(metric.managed)
     mm = metrics.MetricManager("vumi.test.")
     metric.manage(mm)
     self.assertTrue(metric.managed)