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

Async tests for redis commands, json, bloom, timeseries #2087

Merged
merged 14 commits into from
Apr 7, 2022
8 changes: 8 additions & 0 deletions redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ def set_response_callback(self, command: str, callback: ResponseCallbackT):
"""Set a custom Response Callback"""
self.response_callbacks[command] = callback

def get_encoder(self):
"""Get the connection pool's encoder"""
return self.connection_pool.get_encoder()

def get_connection_kwargs(self):
"""Get the connection's key-word arguments"""
return self.connection_pool.connection_kwargs

def load_external_module(
self,
funcname,
Expand Down
12 changes: 11 additions & 1 deletion tests/test_asyncio/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
PythonParser,
parse_url,
)
from redis.asyncio.retry import Retry
from redis.backoff import NoBackoff
from tests.conftest import REDIS_INFO

from .compat import mock
Expand Down Expand Up @@ -97,7 +99,7 @@ async def ateardown():


@pytest_asyncio.fixture()
async def r(create_redis):
async def r(request, create_redis):
yield await create_redis()


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


@pytest_asyncio.fixture()
async def modclient(request, create_redis):
yield await create_redis(
url=request.config.getoption("--redismod-url"), decode_responses=True
)


def _gen_cluster_mock_resp(r, response):
connection = mock.AsyncMock()
connection.retry = Retry(NoBackoff(), 0)
connection.read_response.return_value = response
r.connection = connection
return r
Expand Down
Loading