def test_update(self, time_mock): aggregator = export.aggregate.MinMaxSumCountAggregator() bound_measure = metrics.BoundMeasure(int, True, aggregator) time_mock.return_value = 123 bound_measure.update(4.0) self.assertEqual(bound_measure.last_update_timestamp, 123) self.assertEqual(bound_measure.aggregator.current, (4.0, 4.0, 4.0, 1))
def test_record_disabled(self): aggregator = export.aggregate.MinMaxSumCountAggregator() bound_measure = metrics.BoundMeasure(int, False, aggregator) bound_measure.record(3) self.assertEqual( bound_measure.aggregator.current, (None, None, None, 0) )
def test_record_incorrect_type(self, logger_mock): aggregator = export.aggregate.MinMaxSumCountAggregator() bound_measure = metrics.BoundMeasure(int, True, aggregator) bound_measure.record(3.0) self.assertEqual( bound_measure.aggregator.current, (None, None, None, 0) ) self.assertTrue(logger_mock.warning.called)
def test_record(self): aggregator = export.aggregate.MinMaxSumCountAggregator() bound_measure = metrics.BoundMeasure(int, True, aggregator) bound_measure.record(3) self.assertEqual(bound_measure.aggregator.current, (3, 3, 3, 1))
def test_update(self): aggregator = export.aggregate.MinMaxSumCountAggregator() bound_measure = metrics.BoundMeasure(int, True, aggregator) bound_measure.update(4.0) self.assertEqual(bound_measure.aggregator.current, (4.0, 4.0, 4.0, 1))