Skip to content

Commit ade3b8f

Browse files
committed
Fixed the tests and the resp parser
1 parent 1ce809d commit ade3b8f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

redis/_parsers/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def parse_sentinel_masters(response, **options):
163163

164164

165165
def parse_sentinel_masters_resp3(response, **options):
166-
return [parse_sentinel_state(master) for master in response]
166+
return [parse_sentinel_state_resp3(master) for master in response]
167167

168168

169169
def parse_sentinel_slaves_and_sentinels(response, **options):

tests/test_asyncio/test_sentinel.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
SentinelConnectionPool,
1414
SlaveNotFoundError,
1515
)
16+
from tests.conftest import is_resp2_connection
1617

1718

1819
@pytest_asyncio.fixture(scope="module", loop_scope="module")
@@ -381,7 +382,13 @@ async def test_sentinel_commands_with_strict_redis_client(request):
381382
await client.sentinel_get_master_addr_by_name("redis-py-test"), tuple
382383
)
383384
assert isinstance(await client.sentinel_master("redis-py-test"), dict)
384-
assert isinstance(await client.sentinel_masters(), dict)
385+
if is_resp2_connection(client):
386+
assert isinstance(await client.sentinel_masters(), dict)
387+
else:
388+
masters = await client.sentinel_masters()
389+
assert isinstance(masters, list)
390+
for master in masters:
391+
assert isinstance(master, dict)
385392

386393
assert isinstance(await client.sentinel_sentinels("redis-py-test"), list)
387394
assert isinstance(await client.sentinel_slaves("redis-py-test"), list)

tests/test_sentinel.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
SentinelConnectionPool,
1313
SlaveNotFoundError,
1414
)
15+
from tests.conftest import is_resp2_connection
1516

1617

1718
@pytest.fixture(scope="module")
@@ -358,7 +359,13 @@ def test_sentinel_commands_with_strict_redis_client(request):
358359
# skipping commands that change the state of the sentinel setup
359360
assert isinstance(client.sentinel_get_master_addr_by_name("redis-py-test"), tuple)
360361
assert isinstance(client.sentinel_master("redis-py-test"), dict)
361-
assert isinstance(client.sentinel_masters(), dict)
362+
if is_resp2_connection(client):
363+
assert isinstance(client.sentinel_masters(), dict)
364+
else:
365+
masters = client.sentinel_masters()
366+
assert isinstance(masters, list)
367+
for master in masters:
368+
assert isinstance(master, dict)
362369

363370
assert isinstance(client.sentinel_sentinels("redis-py-test"), list)
364371
assert isinstance(client.sentinel_slaves("redis-py-test"), list)

0 commit comments

Comments
 (0)