Skip to content

Commit 1d25a88

Browse files
committed
reorder
1 parent ff7d9c7 commit 1d25a88

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

tests/test_asyncio/test_sentinel_managed_connection.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ async def mock_connect():
4141
assert conn._connect.call_count == 3
4242
await conn.disconnect()
4343

44-
45-
def same_address(
46-
connection_1: SentinelManagedConnection,
47-
connection_2: SentinelManagedConnection,
48-
) -> bool:
49-
return bool(
50-
connection_1.host == connection_2.host and connection_1.port == connection_2.port
51-
)
52-
5344
class SentinelManagedConnectionMock(SentinelManagedConnection):
5445
async def connect_to_address(self, host: str, port: int) -> None:
5546
self.host = host
@@ -104,7 +95,7 @@ async def connection_pool_replica_mock() -> SentinelConnectionPool:
10495

10596
@pytest_asyncio.fixture()
10697
async def connection_pool_master_mock() -> SentinelConnectionPool:
107-
sentinel_manager = Sentinel([["master", 400]])
98+
sentinel_manager = Sentinel([["master", 400]])
10899
# Give a random slave
109100
sentinel_manager.discover_master = AsyncMock(return_value=["replica", 5000]) # type: ignore[method-assign]
110101
# Create connection pool with our mock connection object
@@ -117,6 +108,14 @@ async def connection_pool_master_mock() -> SentinelConnectionPool:
117108
return connection_pool
118109

119110

111+
def same_address(
112+
connection_1: SentinelManagedConnection,
113+
connection_2: SentinelManagedConnection,
114+
) -> bool:
115+
return bool(
116+
connection_1.host == connection_2.host and connection_1.port == connection_2.port
117+
)
118+
120119
async def test_connection_pool_connects_to_same_address_if_same_iter_req_id_in_replica_mode(
121120
connection_pool_replica_mock: SentinelConnectionPool,
122121
) -> None:
@@ -197,7 +196,7 @@ async def test_connection_pool_connects_to_same_address_if_no_iter_req_id_in_mas
197196
await connection_pool_master_mock.get_connection("ANY_COMMAND"),
198197
connection_for_random_req
199198
)
200-
199+
201200
assert same_address(
202201
await connection_pool_master_mock.get_connection("ANY_COMMAND"),
203202
connection_for_req_1,

0 commit comments

Comments
 (0)