diff options
author | Roey Prat <roey.prat@redislabs.com> | 2018-10-28 11:52:01 +0200 |
---|---|---|
committer | Roey Prat <roey.prat@redislabs.com> | 2018-10-28 14:13:42 +0200 |
commit | 3ba1d14bc74f9a5045d714ce67422ef05b59b724 (patch) | |
tree | eeb0e285f2c8e4fe2f79aa5d2a0948f5ece37113 | |
parent | 4ad035dfc94582d8265572439a2f0bdf41637e79 (diff) | |
download | redis-py-3ba1d14bc74f9a5045d714ce67422ef05b59b724.tar.gz |
allow list based iterating on XREADGROUP results
-rwxr-xr-x | redis/client.py | 9 | ||||
-rw-r--r-- | tests/test_commands.py | 7 |
2 files changed, 7 insertions, 9 deletions
diff --git a/redis/client.py b/redis/client.py index c055496..13c01d0 100755 --- a/redis/client.py +++ b/redis/client.py @@ -266,13 +266,10 @@ def parse_xclaim(response): return stream_list(response) -def multi_stream_list(response): +def parse_xreadgroup(response): if response is None: return None - result = dict() - for r in response: - result[nativestr(r[0])] = stream_list(r[1]) - return result + return [[nativestr(r[0]), stream_list(r[1])] for r in response] def float_or_none(response): @@ -413,7 +410,7 @@ class StrictRedis(object): int ), string_keys_to_dict('XREVRANGE XRANGE', stream_list), - string_keys_to_dict('XREAD XREADGROUP', multi_stream_list), + string_keys_to_dict('XREAD XREADGROUP', parse_xreadgroup), { 'XGROUP CREATE': bool_ok, 'XGROUP DESTROY': int, diff --git a/tests/test_commands.py b/tests/test_commands.py index 70dcbfa..929b4bd 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1692,9 +1692,10 @@ class TestStrictCommands(object): consumer_name = 'captain_jack_sparrow' - assert sr.xreadgroup(groupname=group_name, consumername=consumer_name, - **{stream_name: '0'}) == { - stream_name: [(b(stamp1), b_message)]} + expected_value = [['xgroup_test_stream', [(stamp1, b_message)]]] + assert sr.xreadgroup(groupname=group_name, + consumername=consumer_name, + **{stream_name: '0'}) == expected_value assert sr.xinfo_groups(name=stream_name)[0][b('consumers')] == 1 sr.xgroup_delconsumer(stream_name, group_name, consumer_name) |