Update test object for new Object structure

This commit is contained in:
Lee Miller 2024-09-29 04:55:28 +03:00
parent 210f9c7890
commit a540fac7f8
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63

View File

@ -18,11 +18,12 @@ sample_addr_data = unhexlify(
'260753000201300000000000000057ae1f90') '260753000201300000000000000057ae1f90')
# data for an object with expires_time 1697063939 # data for an object with expires_time 1697063939
# structure.Object( # structure.Object(expires_time, 42, 1, 2, object_payload=b'HELLO').data
# b'\x00' * 8, expires_time, 42, 1, 2, b'HELLO').to_bytes()
sample_object_data = unhexlify( sample_object_data = unhexlify(
'000000000000000000000000652724030000002a010248454c4c4f') '000000000000000000000000652724030000002a010248454c4c4f')
sample_object_expires = 1697063939
logging.basicConfig( logging.basicConfig(
level=shared.log_level, level=shared.log_level,
format='[%(asctime)s] [%(levelname)s] %(message)s') format='[%(asctime)s] [%(levelname)s] %(message)s')
@ -131,9 +132,16 @@ class TestStructure(unittest.TestCase):
message.Message(b'object', sample_object_data)) message.Message(b'object', sample_object_data))
self.assertEqual(obj.object_type, 42) self.assertEqual(obj.object_type, 42)
self.assertEqual(obj.stream_number, 2) self.assertEqual(obj.stream_number, 2)
self.assertEqual(obj.expires_time, 1697063939) self.assertEqual(obj.expires_time, sample_object_expires)
self.assertEqual(obj.object_payload, b'HELLO') self.assertEqual(obj.object_payload, b'HELLO')
obj = structure.Object(
sample_object_expires, 42, 1, 2, object_payload=b'HELLO')
self.assertEqual(obj.data, sample_object_data)
self.assertEqual(obj.offset, 22)
self.assertEqual(obj.nonce, b'\x00' * 8)
self.assertTrue(obj.is_expired())
obj = structure.Object( obj = structure.Object(
int(time.time() + 3000000), 42, 1, 1, object_payload=b'HELLO') int(time.time() + 3000000), 42, 1, 1, object_payload=b'HELLO')
self.assertFalse(obj.is_valid()) self.assertFalse(obj.is_valid())