Added test cases to verify that MessageProperties.msgid is calculated

correctly.
This commit is contained in:
Anthony Tuininga 2021-09-03 13:57:20 -06:00
parent eb37d27464
commit 83148ec574
2 changed files with 30 additions and 0 deletions

View File

@ -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()

View File

@ -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()