From 65fd392a70443932598707c48fbbb9073f3f440c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 8 Dec 2018 12:37:57 +0000 Subject: [PATCH] test getting latest message --- tests/test_pubsub.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_pubsub.py b/tests/test_pubsub.py index 9f2dc72..ed29e30 100644 --- a/tests/test_pubsub.py +++ b/tests/test_pubsub.py @@ -30,6 +30,13 @@ class PubSubTestCase(TestCase): message_ids = [message["data"] for message in all_messages] self.assertEqual(message_ids, [0, 1, 2, 3, 4]) + def test_get_latest_message(self): + for i in range(5): + self.publisher.write({"data": i}) + latest_message = self.subscriber.get_latest_message() + self.assertEqual(latest_message, {"data": 4}) + self.assertIsNone(self.subscriber.get_latest_message()) + def test_multiple_subscribers(self): subscriber_2 = pubsub.Subscriber(self.socket_path) self.publisher.write({"foo": "bar"})