From 83148ec5745ff68f96b7c80e2f589aff0fd05989 Mon Sep 17 00:00:00 2001 From: Anthony Tuininga Date: Fri, 3 Sep 2021 13:57:20 -0600 Subject: [PATCH] Added test cases to verify that MessageProperties.msgid is calculated correctly. --- test/test_2700_aq.py | 16 ++++++++++++++++ test/test_2800_bulk_aq.py | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/test/test_2700_aq.py b/test/test_2700_aq.py index e8f3490..a092de5 100644 --- a/test/test_2700_aq.py +++ b/test/test_2700_aq.py @@ -375,5 +375,21 @@ class TestCase(test_env.BaseTestCase): self.book_queue_name, books_type, payloadType=books_type) + def test_2718_verify_msgid(self): + "2718 - verify that the msgid property is returned correctly" + self.__clear_books_queue() + books_type = self.connection.gettype(self.book_type_name) + book = books_type.newobject() + book.TITLE, book.AUTHORS, book.PRICE = self.book_data[0] + queue = self.connection.queue(self.book_queue_name, books_type) + props = self.connection.msgproperties(payload=book) + self.assertEqual(props.msgid, None) + queue.enqone(props) + self.cursor.execute("select msgid from book_queue_tab") + actual_msgid, = self.cursor.fetchone() + self.assertEqual(props.msgid, actual_msgid) + props = queue.deqone() + self.assertEqual(props.msgid, actual_msgid) + if __name__ == "__main__": test_env.run_test_cases() diff --git a/test/test_2800_bulk_aq.py b/test/test_2800_bulk_aq.py index 3e47b61..a0a94df 100644 --- a/test/test_2800_bulk_aq.py +++ b/test/test_2800_bulk_aq.py @@ -131,5 +131,19 @@ class TestCase(test_env.BaseTestCase): messages = other_queue.deqmany(5) self.assertEqual(len(messages), 0) + def test_2806_verify_msgid(self): + "2806 - verify that the msgid property is returned correctly" + queue = self.__get_and_clear_raw_queue() + messages = [self.connection.msgproperties(payload=d) \ + for d in RAW_PAYLOAD_DATA] + queue.enqmany(messages) + self.cursor.execute("select msgid from raw_queue_tab") + actual_msgids = set(m for m, in self.cursor) + msgids = set(m.msgid for m in messages) + self.assertEqual(msgids, actual_msgids) + messages = queue.deqmany(len(RAW_PAYLOAD_DATA)) + msgids = set(m.msgid for m in messages) + self.assertEqual(msgids, actual_msgids) + if __name__ == "__main__": test_env.run_test_cases()