@@ -41,15 +41,6 @@ async def mock_connect():
41
41
assert conn ._connect .call_count == 3
42
42
await conn .disconnect ()
43
43
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
-
53
44
class SentinelManagedConnectionMock (SentinelManagedConnection ):
54
45
async def connect_to_address (self , host : str , port : int ) -> None :
55
46
self .host = host
@@ -104,7 +95,7 @@ async def connection_pool_replica_mock() -> SentinelConnectionPool:
104
95
105
96
@pytest_asyncio .fixture ()
106
97
async def connection_pool_master_mock () -> SentinelConnectionPool :
107
- sentinel_manager = Sentinel ([["master" , 400 ]])
98
+ sentinel_manager = Sentinel ([["master" , 400 ]])
108
99
# Give a random slave
109
100
sentinel_manager .discover_master = AsyncMock (return_value = ["replica" , 5000 ]) # type: ignore[method-assign]
110
101
# Create connection pool with our mock connection object
@@ -117,6 +108,14 @@ async def connection_pool_master_mock() -> SentinelConnectionPool:
117
108
return connection_pool
118
109
119
110
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
+
120
119
async def test_connection_pool_connects_to_same_address_if_same_iter_req_id_in_replica_mode (
121
120
connection_pool_replica_mock : SentinelConnectionPool ,
122
121
) -> None :
@@ -197,7 +196,7 @@ async def test_connection_pool_connects_to_same_address_if_no_iter_req_id_in_mas
197
196
await connection_pool_master_mock .get_connection ("ANY_COMMAND" ),
198
197
connection_for_random_req
199
198
)
200
-
199
+
201
200
assert same_address (
202
201
await connection_pool_master_mock .get_connection ("ANY_COMMAND" ),
203
202
connection_for_req_1 ,
0 commit comments