def test_reset(self): buffer = Buffer() buffer.records = [1, 2, 3] buffer.time_start = time.time() buffer.reset() self.assertEqual(buffer.records, [], 'Buffer.records should be reset to []') self.assertIsNone(buffer.time_start, 'Buffer.time_start should be reset to None')
def test_on_reset(self): custom_controller = MagicMock() on_reset = MagicMock() buffer = Buffer(custom_controllers=custom_controller, on_reset=on_reset) payload = [1, 2] records = [Record(payload=p) for p in payload] buffer(records) custom_controller.assert_called_with(records) self.assertEqual(on_reset.call_count, 1) buffer.reset() self.assertEqual(on_reset.call_count, 2)