def test_update(self, time_mock):
     aggregator = export.aggregate.CounterAggregator()
     handle = metrics.GaugeHandle(int, True, aggregator)
     time_mock.return_value = 123
     handle.update(4.0)
     self.assertEqual(handle.last_update_timestamp, 123)
     self.assertEqual(handle.aggregator.current, 4.0)
 def test_set_incorrect_type(self, logger_mock):
     aggregator = export.aggregate.CounterAggregator()
     handle = metrics.GaugeHandle(int, True, aggregator)
     handle.set(3.0)
     self.assertEqual(handle.aggregator.current, 0)
     self.assertTrue(logger_mock.warning.called)
 def test_set_disabled(self):
     aggregator = export.aggregate.CounterAggregator()
     handle = metrics.GaugeHandle(int, False, aggregator)
     handle.set(3)
     self.assertEqual(handle.aggregator.current, 0)
Ejemplo n.º 4
0
 def test_set_incorrect_type(self, logger_mock):
     handle = metrics.GaugeHandle(int, True, False)
     handle.set(3.0)
     self.assertEqual(handle.data, 0)
     self.assertTrue(logger_mock.warning.called)
Ejemplo n.º 5
0
 def test_set_monotonic(self, logger_mock):
     handle = metrics.GaugeHandle(int, True, True)
     handle.set(-3)
     self.assertEqual(handle.data, 0)
     self.assertTrue(logger_mock.warning.called)
Ejemplo n.º 6
0
 def test_set_disabled(self):
     handle = metrics.GaugeHandle(int, False, False)
     handle.set(3)
     self.assertEqual(handle.data, 0)
Ejemplo n.º 7
0
 def test_set(self):
     handle = metrics.GaugeHandle(int, True, False)
     handle.set(3)
     self.assertEqual(handle.data, 3)