Add test for lots of and no subscribers

This commit is contained in:
Jake Howard 2018-12-08 13:10:31 +00:00
parent 1352e49f11
commit c6a3126369
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -42,4 +42,16 @@ class PubSubTestCase(TestCase):
self.publisher.write({"foo": "bar"}) self.publisher.write({"foo": "bar"})
self.assertEqual(self.subscriber.get_latest_message(), {"foo": "bar"}) self.assertEqual(self.subscriber.get_latest_message(), {"foo": "bar"})
self.assertEqual(subscriber_2.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"})