File tree 4 files changed +52
-0
lines changed
4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -880,6 +880,7 @@ def to_bool(value) -> Optional[bool]:
880
880
"max_connections" : int ,
881
881
"health_check_interval" : int ,
882
882
"ssl_check_hostname" : to_bool ,
883
+ "timeout" : float ,
883
884
}
884
885
)
885
886
Original file line number Diff line number Diff line change @@ -853,6 +853,7 @@ def to_bool(value):
853
853
"max_connections" : int ,
854
854
"health_check_interval" : int ,
855
855
"ssl_check_hostname" : to_bool ,
856
+ "timeout" : float ,
856
857
}
857
858
858
859
Original file line number Diff line number Diff line change @@ -454,6 +454,31 @@ def test_invalid_scheme_raises_error(self):
454
454
)
455
455
456
456
457
+ class TestBlockingConnectionPoolURLParsing :
458
+ def test_extra_typed_querystring_options (self ):
459
+ pool = redis .BlockingConnectionPool .from_url (
460
+ "redis://localhost/2?socket_timeout=20&socket_connect_timeout=10"
461
+ "&socket_keepalive=&retry_on_timeout=Yes&max_connections=10&timeout=13.37"
462
+ )
463
+
464
+ assert pool .connection_class == redis .Connection
465
+ assert pool .connection_kwargs == {
466
+ "host" : "localhost" ,
467
+ "db" : 2 ,
468
+ "socket_timeout" : 20.0 ,
469
+ "socket_connect_timeout" : 10.0 ,
470
+ "retry_on_timeout" : True ,
471
+ }
472
+ assert pool .max_connections == 10
473
+ assert pool .timeout == 13.37
474
+
475
+ def test_invalid_extra_typed_querystring_options (self ):
476
+ with pytest .raises (ValueError ):
477
+ redis .BlockingConnectionPool .from_url (
478
+ "redis://localhost/2?timeout=_not_a_float_"
479
+ )
480
+
481
+
457
482
class TestConnectionPoolUnixSocketURLParsing :
458
483
def test_defaults (self ):
459
484
pool = redis .ConnectionPool .from_url ("unix:///socket" )
Original file line number Diff line number Diff line change @@ -359,6 +359,31 @@ def test_invalid_scheme_raises_error_when_double_slash_missing(self):
359
359
)
360
360
361
361
362
+ class TestBlockingConnectionPoolURLParsing :
363
+ def test_extra_typed_querystring_options (self ):
364
+ pool = redis .BlockingConnectionPool .from_url (
365
+ "redis://localhost/2?socket_timeout=20&socket_connect_timeout=10"
366
+ "&socket_keepalive=&retry_on_timeout=Yes&max_connections=10&timeout=42"
367
+ )
368
+
369
+ assert pool .connection_class == redis .Connection
370
+ assert pool .connection_kwargs == {
371
+ "host" : "localhost" ,
372
+ "db" : 2 ,
373
+ "socket_timeout" : 20.0 ,
374
+ "socket_connect_timeout" : 10.0 ,
375
+ "retry_on_timeout" : True ,
376
+ }
377
+ assert pool .max_connections == 10
378
+ assert pool .timeout == 42.0
379
+
380
+ def test_invalid_extra_typed_querystring_options (self ):
381
+ with pytest .raises (ValueError ):
382
+ redis .BlockingConnectionPool .from_url (
383
+ "redis://localhost/2?timeout=_not_a_float_"
384
+ )
385
+
386
+
362
387
class TestConnectionPoolUnixSocketURLParsing :
363
388
def test_defaults (self ):
364
389
pool = redis .ConnectionPool .from_url ("unix:///socket" )
You can’t perform that action at this time.
0 commit comments