From 0d3da4e1bb3660285694b27c19c8d2498f0d42e7 Mon Sep 17 00:00:00 2001 From: rapidia Date: Mon, 30 May 2022 19:19:19 +0900 Subject: set default response_callbacks to redis.asyncio.cluster.ClusterNode (#2201) * set default response_callbacks to redis.asyncio.cluster.ClusterNode * add test case for ClusterNode class * fix lint error * merge test case into `test_startup_nodes` --- redis/asyncio/cluster.py | 2 +- tests/test_asyncio/test_cluster.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/redis/asyncio/cluster.py b/redis/asyncio/cluster.py index 10a5675..fa91872 100644 --- a/redis/asyncio/cluster.py +++ b/redis/asyncio/cluster.py @@ -725,7 +725,7 @@ class ClusterNode: server_type: Optional[str] = None, max_connections: int = 2 ** 31, connection_class: Type[Connection] = Connection, - response_callbacks: Dict = None, + response_callbacks: Dict = RedisCluster.RESPONSE_CALLBACKS, **connection_kwargs, ) -> None: if host == "localhost": diff --git a/tests/test_asyncio/test_cluster.py b/tests/test_asyncio/test_cluster.py index 6543e28..6c28ce3 100644 --- a/tests/test_asyncio/test_cluster.py +++ b/tests/test_asyncio/test_cluster.py @@ -244,6 +244,11 @@ class TestRedisClusterObj: await cluster.close() + startup_nodes = [ClusterNode("127.0.0.1", 16379)] + async with RedisCluster(startup_nodes=startup_nodes) as rc: + assert await rc.set("A", 1) + assert await rc.get("A") == b"1" + async def test_empty_startup_nodes(self) -> None: """ Test that exception is raised when empty providing empty startup_nodes -- cgit v1.2.1