def test_update(self, time_mock): time_mock.return_value = 123 observer = LastValueAggregator() # test current values without any update self.assertIsNone(observer.current) # call update with some values values = (3, 50, 3, 97, 27) for val in values: observer.update(val) self.assertEqual(observer.last_update_timestamp, 123) self.assertEqual(observer.current, values[-1])
def test_checkpoint(self): observer = LastValueAggregator() # take checkpoint without any update observer.take_checkpoint() self.assertEqual(observer.checkpoint, None) # call update with some values values = (3, 50, 3, 97) for val in values: observer.update(val) observer.take_checkpoint() self.assertEqual(observer.checkpoint, 97)