Skip to content

Commit

Permalink
skip test sentinel managed connection if hirediswq
Browse files Browse the repository at this point in the history
  • Loading branch information
agnesnatasya committed Jul 20, 2024
1 parent 4c59821 commit 25777cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion redis/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,9 @@ def __init__(
self.connection_kwargs = connection_kwargs
self.max_connections = max_connections

self._available_connections: ConnectionsIndexer = ConnectionsIndexer()
self._available_connections: ConnectionsIndexer = (
ConnectionsIndexer() if index_available_connections else []
)
self._in_use_connections: Set[AbstractConnection] = set()
self._index_available_connections = index_available_connections
self.encoder_class = self.connection_kwargs.get("encoder_class", Encoder)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_asyncio/test_sentinel_managed_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def same_address(
)


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
async def test_connects_to_same_address_if_same_id_replica(
connection_pool_replica_mock: SentinelConnectionPool,
) -> None:
Expand All @@ -128,6 +129,7 @@ async def test_connects_to_same_address_if_same_id_replica(
)


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
async def test_connects_to_same_conn_object_if_same_id_and_conn_released_replica(
connection_pool_replica_mock: SentinelConnectionPool,
) -> None:
Expand All @@ -148,6 +150,7 @@ async def test_connects_to_same_conn_object_if_same_id_and_conn_released_replica
)


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
async def test_connects_to_diff_address_if_no_iter_req_id_replica(
connection_pool_replica_mock: SentinelConnectionPool,
) -> None:
Expand All @@ -173,6 +176,7 @@ async def test_connects_to_diff_address_if_no_iter_req_id_replica(
)


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
async def test_connects_to_same_address_if_same_iter_req_id_master(
connection_pool_master_mock: SentinelConnectionPool,
) -> None:
Expand All @@ -190,6 +194,7 @@ async def test_connects_to_same_address_if_same_iter_req_id_master(
)


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
async def test_connects_to_same_conn_object_if_same_iter_req_id_and_released_master(
connection_pool_master_mock: SentinelConnectionPool,
) -> None:
Expand All @@ -209,6 +214,7 @@ async def test_connects_to_same_conn_object_if_same_iter_req_id_and_released_mas
)


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
async def test_connects_to_same_address_if_no_iter_req_id_master(
connection_pool_master_mock: SentinelConnectionPool,
) -> None:
Expand All @@ -234,6 +240,7 @@ async def test_connects_to_same_address_if_no_iter_req_id_master(
)


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
async def test_scan_iter_family_cleans_up(
connection_pool_replica_mock: SentinelConnectionPool,
):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sentinel_managed_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from redis import Redis
from redis.sentinel import Sentinel, SentinelConnectionPool, SentinelManagedConnection

pytestmark = pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")


class SentinelManagedConnectionMock(SentinelManagedConnection):
def _connect_to_sentinel(self) -> None:
Expand Down

0 comments on commit 25777cf

Please sign in to comment.