@@ -199,35 +199,41 @@ def test_hello_passes_routing_metadata(fake_socket_pair):
199
199
assert fields [0 ]["routing" ] == {"foo" : "bar" }
200
200
201
201
202
- @pytest .mark .parametrize (("recv_timeout" , "valid" ), (
203
- (1 , True ),
204
- (42 , True ),
205
- (- 1 , False ),
206
- (0 , False ),
207
- (2.5 , False ),
208
- (None , False ),
209
- ("1" , False ),
202
+ @pytest .mark .parametrize (("hints" , "valid" ), (
203
+ ({"connection.recv_timeout_seconds" : 1 }, True ),
204
+ ({"connection.recv_timeout_seconds" : 42 }, True ),
205
+ ({}, True ),
206
+ ({"whatever_this_is" : "ignore me!" }, True ),
207
+ ({"connection.recv_timeout_seconds" : - 1 }, False ),
208
+ ({"connection.recv_timeout_seconds" : 0 }, False ),
209
+ ({"connection.recv_timeout_seconds" : 2.5 }, False ),
210
+ ({"connection.recv_timeout_seconds" : None }, False ),
211
+ ({"connection.recv_timeout_seconds" : False }, False ),
212
+ ({"connection.recv_timeout_seconds" : "1" }, False ),
210
213
))
211
- def test_hint_recv_timeout_seconds (fake_socket_pair , recv_timeout , valid ,
214
+ def test_hint_recv_timeout_seconds (fake_socket_pair , hints , valid ,
212
215
caplog ):
213
216
address = ("127.0.0.1" , 7687 )
214
217
sockets = fake_socket_pair (address )
215
218
sockets .client .settimeout = MagicMock ()
216
- sockets .server .send_message (0x70 , {
217
- "server" : "Neo4j/4.2.0" ,
218
- "hints" : {"connection.recv_timeout_seconds" : recv_timeout },
219
- })
219
+ sockets .server .send_message (0x70 , {"server" : "Neo4j/4.3.0" , "hints" : hints })
220
220
connection = Bolt4x3 (address , sockets .client ,
221
221
PoolConfig .max_connection_lifetime )
222
222
with caplog .at_level (logging .INFO ):
223
223
connection .hello ()
224
- invalid_value_logged = any (repr (recv_timeout ) in msg
225
- and "recv_timeout_seconds" in msg
226
- and "invalid" in msg
227
- for msg in caplog .messages )
228
224
if valid :
229
- sockets .client .settimeout .assert_called_once_with (recv_timeout )
230
- assert not invalid_value_logged
225
+ if "connection.recv_timeout_seconds" in hints :
226
+ sockets .client .settimeout .assert_called_once_with (
227
+ hints ["connection.recv_timeout_seconds" ]
228
+ )
229
+ else :
230
+ sockets .client .settimeout .assert_not_called ()
231
+ assert not any ("recv_timeout_seconds" in msg
232
+ and "invalid" in msg
233
+ for msg in caplog .messages )
231
234
else :
232
235
sockets .client .settimeout .assert_not_called ()
233
- assert invalid_value_logged
236
+ assert any (repr (hints ["connection.recv_timeout_seconds" ]) in msg
237
+ and "recv_timeout_seconds" in msg
238
+ and "invalid" in msg
239
+ for msg in caplog .messages )
0 commit comments