Make an object from sample data in test_object()

This commit is contained in:
Lee Miller 2023-10-12 03:30:49 +03:00
parent d4fbc35d7d
commit cdece735ce
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
1 changed files with 13 additions and 5 deletions

View File

@ -17,6 +17,12 @@ sample_addr_data = unhexlify(
'0000000060f420b3000000010000000000000001'
'260753000201300000000000000057ae1f90')
# data for object with expires_time 1697063939
# structure.Object(
# b'\x00' * 8, expires_time, 42, 1, 2, b'HELLO').to_bytes()
sample_object_data = unhexlify(
'000000000000000000000000652724030000002a010248454c4c4f')
logging.basicConfig(
level=shared.log_level,
format='[%(asctime)s] [%(levelname)s] %(message)s')
@ -100,6 +106,13 @@ class TestStructure(unittest.TestCase):
def test_object(self):
"""Create and check objects"""
obj = structure.Object.from_message(
message.Message(b'object', sample_object_data))
self.assertEqual(obj.object_type, 42)
self.assertEqual(obj.stream_number, 2)
self.assertEqual(obj.expires_time, 1697063939)
self.assertEqual(obj.object_payload, b'HELLO')
obj = structure.Object(
b'\x00' * 8, int(time.time() + 3000000), 42, 1, 1, b'HELLO')
self.assertFalse(obj.is_valid())
@ -117,11 +130,6 @@ class TestStructure(unittest.TestCase):
shared.stream = 2
self.assertTrue(obj.is_valid())
obj = structure.Object.from_message(
message.Message(b'object', obj.to_bytes()))
self.assertEqual(obj.object_type, 42)
self.assertEqual(obj.object_payload, b'HELLO')
obj.object_payload = \
b'TIGER, tiger, burning bright. In the forests of the night'
self.assertFalse(obj.is_valid())