class PubSubTestCase(unittest.TestCase): def setUp(self): self.pubsub = PubSub() self.channel1 = "test-PubSub1" self.channel2 = "test-PubSub2" def test_subscribe(self): self.assertEqual(self.pubsub.subscribe(self.channel1), 0) subs = self.pubsub.publish(self.channel2, "1st") self.assertEqual(subs, 0) self.pubsub.subscribe(self.channel2) subs = self.pubsub.publish(self.channel2, "2nd") self.assertEqual(subs, 1) msg = self.pubsub.get_message() self.assertEqual(msg, "2nd") def tearDown(self): pass
def setUp(self): self.pubsub = PubSub() self.channel1 = "test-PubSub1" self.channel2 = "test-PubSub2"