def test_basic_interaction(self): self.assertIsNone(state_handler.get_checksum(0)) checksum = '397fc6229a59429ee114441b780fe7a2' state_handler.set_checksum(0, checksum) self.assertEqual(state_handler.get_checksum(0), checksum) state_handler.clear_checksum(0) self.assertIsNone(state_handler.get_checksum(0))
def test_basic_interaction(self): self.assertIsNone(state_handler.get_checksum(0)) checksum = "397fc6229a59429ee114441b780fe7a2" state_handler.set_checksum(0, checksum) self.assertEqual(state_handler.get_checksum(0), checksum) state_handler.clear_checksum(0) self.assertIsNone(state_handler.get_checksum(0))
def test_flush(self): state_handler.set_checksum(0, '6818bab4da85a3a138cdfa35cfc7a64f') self.assertEqual(state_handler.get_checksum(0), '6818bab4da85a3a138cdfa35cfc7a64f') state_handler.flush() self.assertEqual(state_handler.checksums, {}) self.assertNotEqual(state_handler.timestamps, {})
def test_receive(self): state_handler.set_checksum(0, '6818bab4da85a3a138cdfa35cfc7a64f') timestamp = state_handler.timestamps[0] state_handler.receive(0, 'before', timestamp - 1) self.assertEqual(state_handler.get_checksum(0), '6818bab4da85a3a138cdfa35cfc7a64f') state_handler.receive(0, 'before', timestamp + 1) self.assertEqual(state_handler.get_checksum(0), 'before') state_handler.receive(0, None, timestamp + 1) self.assertIsNone(state_handler.get_checksum(0))
def test_checksum_persistence(self): """Make sure checksums are shared between threads.""" checksum = "397fc6229a59429ee114441b780fe7a2" state_handler.set_checksum(0, checksum) getter = ChecksumGetter(0) getter.start() getter.join() self.assertEqual(getter.checksum, checksum) state_handler.clear_checksum(0) getter = ChecksumGetter(0) getter.start() getter.join() self.assertIsNone(getter.checksum)
def test_checksum_persistence(self): """Make sure checksums are shared between threads.""" checksum = '397fc6229a59429ee114441b780fe7a2' state_handler.set_checksum(0, checksum) getter = ChecksumGetter(0) getter.start() getter.join() self.assertEqual(getter.checksum, checksum) state_handler.clear_checksum(0) getter = ChecksumGetter(0) getter.start() getter.join() self.assertIsNone(getter.checksum)