Example #1
0
 def test_channel_subscribe(self):
     self.assertEquals(self.pubsub.subscribe("foo"), ["subscribe".encode(), "foo".encode(), 1])
     self.assertEquals(self.client.publish("foo", "hello foo"), 1)
     self.assertEquals(
         next(self.pubsub.listen()),
         {"type": "message".encode(), "pattern": None, "channel": "foo".encode(), "data": "hello foo".encode()},
     )
     self.assertEquals(self.pubsub.unsubscribe("foo"), ["unsubscribe".encode(), "foo".encode(), 0])
Example #2
0
 def test_pattern_subscribe(self):
     self.assertEquals(self.pubsub.psubscribe("fo*"), ["psubscribe".encode(), "fo*".encode(), 1])
     self.assertEquals(self.client.publish("foo", "hello foo"), 1)
     self.assertEquals(
         next(self.pubsub.listen()),
         {
             "type": "pmessage".encode(),
             "pattern": "fo*".encode(),
             "channel": "foo".encode(),
             "data": "hello foo".encode(),
         },
     )
     self.assertEquals(self.pubsub.punsubscribe("fo*"), ["punsubscribe".encode(), "fo*".encode(), 0])