Skip to content

Commit

Permalink
change tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin on chickenita committed Oct 8, 2024
1 parent 710c5c4 commit 09f8079
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 7 additions & 9 deletions pypeman/tests/test_msgstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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))
Expand All @@ -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!")

Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pypeman/tests/test_remoteadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit 09f8079

Please sign in to comment.