From c6a3126369837614942f7f08d3e6361c4f86214e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 8 Dec 2018 13:10:31 +0000 Subject: [PATCH] Add test for lots of and no subscribers --- tests/test_pubsub.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_pubsub.py b/tests/test_pubsub.py index ed29e30..38e099f 100644 --- a/tests/test_pubsub.py +++ b/tests/test_pubsub.py @@ -42,4 +42,16 @@ class PubSubTestCase(TestCase): self.publisher.write({"foo": "bar"}) self.assertEqual(self.subscriber.get_latest_message(), {"foo": "bar"}) self.assertEqual(subscriber_2.get_latest_message(), {"foo": "bar"}) - subscriber_2.close() + + def test_lots_of_subscribers(self): + subscribers = [] + for i in range(100): + subscribers.append(pubsub.Subscriber(self.socket_path)) + self.publisher.write({"foo": "bar"}) + for subscriber in subscribers: + self.assertEqual(subscriber.get_latest_message(), {"foo": "bar"}) + subscriber.close() + + def test_no_subscribers(self): + self.subscriber.close() + self.publisher.write({"foo": "bar"})