Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESP3 fix async tests #2806

Merged
merged 3 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,8 @@ class AbstractRedis:
"HGETALL": lambda r: r and pairs_to_dict(r) or {},
"MEMORY STATS": parse_memory_stats,
"MODULE LIST": lambda r: [pairs_to_dict(m) for m in r],
"STRALGO": parse_stralgo,
"ACL LIST": lambda r: list(map(str_if_bytes, r)),
# **string_keys_to_dict(
# "COPY "
# "HEXISTS HMSET MOVE MSETNX PERSIST "
Expand All @@ -833,7 +835,6 @@ class AbstractRedis:
# **string_keys_to_dict("ZRANK ZREVRANK", int_or_none),
# **string_keys_to_dict("BGREWRITEAOF BGSAVE", lambda r: True),
# "ACL HELP": lambda r: list(map(str_if_bytes, r)),
# "ACL LIST": lambda r: list(map(str_if_bytes, r)),
# "ACL LOAD": bool_ok,
# "ACL SAVE": bool_ok,
# "ACL USERS": lambda r: list(map(str_if_bytes, r)),
Expand All @@ -855,7 +856,6 @@ class AbstractRedis:
# "MODULE UNLOAD": parse_module_result,
# "OBJECT": parse_object,
# "QUIT": bool_ok,
# "STRALGO": parse_stralgo,
# "RANDOMKEY": lambda r: r and r or None,
# "SCRIPT EXISTS": lambda r: list(map(bool, r)),
# "SCRIPT KILL": bool_ok,
Expand Down
11 changes: 6 additions & 5 deletions tests/test_asyncio/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ class TestResponseCallbacks:
"""Tests for the response callback system"""

async def test_response_callbacks(self, r: redis.Redis):
resp3_callbacks = redis.Redis.RESPONSE_CALLBACKS.copy()
resp3_callbacks.update(redis.Redis.RESP3_RESPONSE_CALLBACKS)
assert_resp_response(
r, r.response_callbacks, redis.Redis.RESPONSE_CALLBACKS, resp3_callbacks
)
callbacks = redis.Redis.RESPONSE_CALLBACKS
if is_resp2_connection(r):
callbacks.update(redis.Redis.RESP2_RESPONSE_CALLBACKS)
else:
callbacks.update(redis.Redis.RESP3_RESPONSE_CALLBACKS)
assert r.response_callbacks == callbacks
assert id(r.response_callbacks) != id(redis.Redis.RESPONSE_CALLBACKS)
r.set_response_callback("GET", lambda x: "static")
await r.set("a", "foo")
Expand Down
4 changes: 3 additions & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ class TestResponseCallbacks:

def test_response_callbacks(self, r):
callbacks = redis.Redis.RESPONSE_CALLBACKS
if not is_resp2_connection(r):
if is_resp2_connection(r):
callbacks.update(redis.Redis.RESP2_RESPONSE_CALLBACKS)
else:
callbacks.update(redis.Redis.RESP3_RESPONSE_CALLBACKS)
assert r.response_callbacks == callbacks
assert id(r.response_callbacks) != id(redis.Redis.RESPONSE_CALLBACKS)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ def test_change_username_password_on_existing_connection(self, r, request):
password = "origin_password"
new_username = "new_username"
new_password = "new_password"

def teardown():
r.acl_deluser(new_username)

request.addfinalizer(teardown)

init_acl_user(r, request, username, password)
r2 = _get_client(
redis.Redis, request, flushdb=False, username=username, password=password
Expand Down