From 09f80794e3b324044d6f4d004831eb415e5a3e1f Mon Sep 17 00:00:00 2001 From: quentin on chickenita Date: Tue, 8 Oct 2024 11:36:11 +0200 Subject: [PATCH] change tests --- pypeman/tests/test_msgstore.py | 16 +++++++--------- pypeman/tests/test_remoteadmin.py | 7 ++++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pypeman/tests/test_msgstore.py b/pypeman/tests/test_msgstore.py index 18392d6..cdb1168 100644 --- a/pypeman/tests/test_msgstore.py +++ b/pypeman/tests/test_msgstore.py @@ -98,7 +98,7 @@ def test_memory_message_store(self): msg5 = generate_msg(timestamp=(1982, 11, 12, 14, 35), message_content='{"test1": "shall_fail"}') msg6 = generate_msg(timestamp=(1982, 11, 28, 14, 35), message_content=ObjectWithoutStr()) - + msg2_uuid = msg2.uuid chan.add(n) chan.add(n_error) @@ -149,7 +149,7 @@ def test_memory_message_store(self): self.assertEqual(dict_msg['state'], 'error', "Message %s should be in error state!" % msg5) # Test list messages - msgs = self.loop.run_until_complete(chan.message_store.search(start=2, count=5)) + msgs = self.loop.run_until_complete(chan.message_store.search(start_id=msg2_uuid, count=5)) self.assertEqual(len(msgs), 4, "Failure of listing messages from memory msg store") # Test list messages with date filters @@ -245,7 +245,6 @@ def test_file_message_store(self): msg5 = generate_msg(timestamp=(1982, 11, 12, 14, 35), message_content='{"test1": "shall_fail"}') msg6 = generate_msg(timestamp=(1982, 11, 28, 14, 35), message_content=ObjectWithoutStr()) - chan.add(n) chan.add(n_error) @@ -255,7 +254,6 @@ def test_file_message_store(self): self.loop.run_until_complete(chan.handle(msg2)) self.loop.run_until_complete(chan.handle(msg3)) self.loop.run_until_complete(chan.handle(msg4)) - with self.assertRaises(TstException): # This message should be in error state self.loop.run_until_complete(chan.handle(msg5)) @@ -264,14 +262,14 @@ def test_file_message_store(self): self.assertEqual(self.loop.run_until_complete(chan.message_store.total()), 6, "Should be a total of 6 messages in store!") - msg_stored1 = list(self.loop.run_until_complete(chan.message_store.search(0, 2))) + msg_stored = list(self.loop.run_until_complete(chan.message_store.search())) + msg2_id = msg_stored[1]["id"] + msg_stored1 = list(self.loop.run_until_complete(chan.message_store.search(count=2))) self.assertEqual(len(msg_stored1), 2, "Should be 2 results from search!") - msg_stored2 = list(self.loop.run_until_complete(chan.message_store.search(2, 5))) + msg_stored2 = list(self.loop.run_until_complete(chan.message_store.search(start_id=msg2_id, count=5))) self.assertEqual(len(msg_stored2), 4, "Should be 4 results from search!") - msg_stored = list(self.loop.run_until_complete(chan.message_store.search())) - # All message stored ? self.assertEqual(len(msg_stored), 6, "Should be 6 messages in store!") @@ -300,7 +298,7 @@ def test_file_message_store(self): % (tempdir, chan.name, msg3.uuid))) # Test list messages - msgs = self.loop.run_until_complete(chan.message_store.search(start=2, count=5)) + msgs = self.loop.run_until_complete(chan.message_store.search(start_id=msg2_id, count=5)) self.assertEqual(len(msgs), 4, "Failure of listing messages for file msg store") # Test list messages with date filters diff --git a/pypeman/tests/test_remoteadmin.py b/pypeman/tests/test_remoteadmin.py index be09f5d..ff14691 100644 --- a/pypeman/tests/test_remoteadmin.py +++ b/pypeman/tests/test_remoteadmin.py @@ -110,7 +110,8 @@ def test_remote_admin_list(self): self.assertEqual(chan.status, BaseChannel.WAITING, "Starting channel doesn't work") # Search message - msg_list = client.list_msgs(channel='test_remote050', start=2, count=5, order_by='-timestamp') + msg_list = client.list_msgs( + channel='test_remote050', start_id=msg4.uuid, count=5, order_by='-timestamp') print(msg_list) @@ -147,14 +148,14 @@ def test_remote_admin_list(self): # Replay message result = client.replay_msg('test_remote050', idref_msg3) - msg_list = client.list_msgs(channel='test_remote050', start=0, count=5, order_by='-timestamp') + msg_list = client.list_msgs(channel='test_remote050', count=5, order_by='-timestamp') self.assertEqual(msg_list['total'], 5, 'List channel messages broken') self.assertEqual(msg_list['messages'][0]['id'], result.uuid, 'Replay messages broken') # Push message result = client.push_msg(channel='test_remote050', text="Yaaay") - msg_list = client.list_msgs(channel='test_remote050', start=0, count=5, order_by='-timestamp') + msg_list = client.list_msgs(channel='test_remote050', count=5, order_by='-timestamp') self.assertEqual(msg_list['total'], 6, 'Push message broken') self.assertEqual(msg_list['messages'][0]['id'], result.uuid, 'Push message broken')