diff options
| author | Krishan Patel <krishan.patel@carbonnv.com> | 2018-08-13 20:08:35 +0100 |
|---|---|---|
| committer | Krishan Patel <krishan.patel@carbonnv.com> | 2018-08-13 20:08:35 +0100 |
| commit | ca600053a333a2962d8d15cfb7b92eddbc5123bf (patch) | |
| tree | 77292c3a52239d53105db2f120288aad9f486b41 | |
| parent | f95b27ee1b74952317280f751c59c0ff32d2ffea (diff) | |
| download | redis-py-ca600053a333a2962d8d15cfb7b92eddbc5123bf.tar.gz | |
Added test
| -rwxr-xr-x | redis/client.py | 2 | ||||
| -rw-r--r-- | tests/test_pubsub.py | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py index db68378..bc62aa0 100755 --- a/redis/client.py +++ b/redis/client.py @@ -2574,7 +2574,7 @@ class PubSub(object): if handler: handler(message) return None - else: + elif message_type != 'pong': # this is a subscribe/unsubscribe message. ignore if we don't # want them if ignore_subscribe_messages or self.ignore_subscribe_messages: diff --git a/tests/test_pubsub.py b/tests/test_pubsub.py index a240248..68a1729 100644 --- a/tests/test_pubsub.py +++ b/tests/test_pubsub.py @@ -27,7 +27,7 @@ def make_message(type, channel, data, pattern=None): return { 'type': type, 'pattern': pattern and pattern.encode('utf-8') or None, - 'channel': channel.encode('utf-8'), + 'channel': channel and channel.encode('utf-8') or None, 'data': data.encode('utf-8') if isinstance(data, basestring) else data } @@ -427,3 +427,15 @@ class TestPubSubPubSubSubcommands(object): p = r.pubsub(ignore_subscribe_messages=True) p.psubscribe('*oo', '*ar', 'b*z') assert r.pubsub_numpat() == 3 + + +class TestPubSubPings(object): + + @skip_if_server_version_lt('3.0.0') + def test_send_pubsub_ping(self, r): + p = r.pubsub(ignore_subscribe_messages=True) + p.subscribe('foo') + p.ping() + assert wait_for_message(p) == make_message(type='pong', channel=None, + data='', + pattern=None) |
