Skip to content

Commit

Permalink
Async tests for redis commands, json, bloom, timeseries (#2087)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dvora-h committed Apr 7, 2022
1 parent 20e4b87 commit cb91eed
Show file tree
Hide file tree
Showing 7 changed files with 4,991 additions and 2 deletions.
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

0 comments on commit cb91eed

Please sign in to comment.