summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrishan Patel <krishan.patel@carbonnv.com>2018-08-13 20:08:35 +0100
committerKrishan Patel <krishan.patel@carbonnv.com>2018-08-13 20:08:35 +0100
commitca600053a333a2962d8d15cfb7b92eddbc5123bf (patch)
tree77292c3a52239d53105db2f120288aad9f486b41
parentf95b27ee1b74952317280f751c59c0ff32d2ffea (diff)
downloadredis-py-ca600053a333a2962d8d15cfb7b92eddbc5123bf.tar.gz
Added test
-rwxr-xr-xredis/client.py2
-rw-r--r--tests/test_pubsub.py14
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)