|
3 | 3 |
|
4 | 4 | import pytest |
5 | 5 | import pytest_asyncio |
| 6 | +from redis.asyncio.client import StrictRedis |
| 7 | + |
6 | 8 | import redis.asyncio.sentinel |
7 | 9 | from redis import exceptions |
8 | 10 | from redis.asyncio.sentinel import ( |
@@ -363,3 +365,27 @@ async def test_redis_master_usage(deployed_sentinel): |
363 | 365 | r = await deployed_sentinel.master_for("redis-py-test", db=0) |
364 | 366 | await r.set("foo", "bar") |
365 | 367 | assert (await r.get("foo")) == "bar" |
| 368 | + |
| 369 | + |
| 370 | +@pytest.mark.onlynoncluster |
| 371 | +async def test_sentinel_commands_with_strict_redis_client(request): |
| 372 | + sentinel_ips = request.config.getoption("--sentinels") |
| 373 | + sentinel_host, sentinel_port = sentinel_ips.split(",")[0].split(":") |
| 374 | + protocol = request.config.getoption("--protocol", 2) |
| 375 | + |
| 376 | + client = StrictRedis( |
| 377 | + host=sentinel_host, port=sentinel_port, decode_responses=True, protocol=protocol |
| 378 | + ) |
| 379 | + # skipping commands that change the state of the sentinel setup |
| 380 | + assert isinstance( |
| 381 | + await client.sentinel_get_master_addr_by_name("redis-py-test"), tuple |
| 382 | + ) |
| 383 | + assert isinstance(await client.sentinel_master("redis-py-test"), dict) |
| 384 | + assert isinstance(await client.sentinel_masters(), dict) |
| 385 | + |
| 386 | + assert isinstance(await client.sentinel_sentinels("redis-py-test"), list) |
| 387 | + assert isinstance(await client.sentinel_slaves("redis-py-test"), list) |
| 388 | + |
| 389 | + assert isinstance(await client.sentinel_ckquorum("redis-py-test"), bool) |
| 390 | + |
| 391 | + await client.close() |
0 commit comments