Skip to content

Commit cb91eed

Browse files
authored
Async tests for redis commands, json, bloom, timeseries (#2087)
* test async commands * test async json commands * test async timeseries commands * test async bloom commands * linters * linters * skip on cluster * linters * linters * isort * flynt * remove print
1 parent 20e4b87 commit cb91eed

File tree

7 files changed

+4991
-2
lines changed

7 files changed

+4991
-2
lines changed

redis/asyncio/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ def set_response_callback(self, command: str, callback: ResponseCallbackT):
255255
"""Set a custom Response Callback"""
256256
self.response_callbacks[command] = callback
257257

258+
def get_encoder(self):
259+
"""Get the connection pool's encoder"""
260+
return self.connection_pool.get_encoder()
261+
262+
def get_connection_kwargs(self):
263+
"""Get the connection's key-word arguments"""
264+
return self.connection_pool.connection_kwargs
265+
258266
def load_external_module(
259267
self,
260268
funcname,

tests/test_asyncio/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
PythonParser,
2121
parse_url,
2222
)
23+
from redis.asyncio.retry import Retry
24+
from redis.backoff import NoBackoff
2325
from tests.conftest import REDIS_INFO
2426

2527
from .compat import mock
@@ -97,7 +99,7 @@ async def ateardown():
9799

98100

99101
@pytest_asyncio.fixture()
100-
async def r(create_redis):
102+
async def r(request, create_redis):
101103
yield await create_redis()
102104

103105

@@ -107,8 +109,16 @@ async def r2(create_redis):
107109
yield await create_redis()
108110

109111

112+
@pytest_asyncio.fixture()
113+
async def modclient(request, create_redis):
114+
yield await create_redis(
115+
url=request.config.getoption("--redismod-url"), decode_responses=True
116+
)
117+
118+
110119
def _gen_cluster_mock_resp(r, response):
111120
connection = mock.AsyncMock()
121+
connection.retry = Retry(NoBackoff(), 0)
112122
connection.read_response.return_value = response
113123
r.connection = connection
114124
return r

0 commit comments

Comments
 (0)