From cdece735ce794325a18069dfe141860543106ac3 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Thu, 12 Oct 2023 03:30:49 +0300 Subject: [PATCH] Make an object from sample data in test_object() --- minode/tests/test_structure.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/minode/tests/test_structure.py b/minode/tests/test_structure.py index 68ace3a..0d99344 100644 --- a/minode/tests/test_structure.py +++ b/minode/tests/test_structure.py @@ -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())