File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def __init__(
4949 api_url : typing .Optional [str ] = None ,
5050 realtime_api_url : typing .Optional [str ] = None ,
5151 custom_headers : typing .Optional [typing .Dict [str , typing .Any ]] = None ,
52- request_timeout_seconds : typing .Optional [int ] = None ,
52+ request_timeout_seconds : typing .Optional [int ] = 10 ,
5353 enable_local_evaluation : bool = False ,
5454 environment_refresh_interval_seconds : typing .Union [int , float ] = 60 ,
5555 retries : typing .Optional [Retry ] = None ,
Original file line number Diff line number Diff line change @@ -278,6 +278,39 @@ def test_non_200_response_raises_flagsmith_api_error(flagsmith: Flagsmith) -> No
278278 # expected exception raised
279279
280280
281+ @pytest .mark .parametrize (
282+ "settings, expected_timeout" ,
283+ [
284+ ({"request_timeout_seconds" : 5 }, 5 ), # Arbitrary timeout
285+ ({"request_timeout_seconds" : None }, None ), # No timeout is forced
286+ ({}, 10 ), # Default timeout
287+ ],
288+ )
289+ def test_request_times_out_according_to_setting (
290+ mocker : MockerFixture ,
291+ api_key : str ,
292+ settings : typing .Dict [str , typing .Any ],
293+ expected_timeout : typing .Optional [int ],
294+ ) -> None :
295+ # Given
296+ session = mocker .patch ("flagsmith.flagsmith.requests.Session" ).return_value
297+ flagsmith = Flagsmith (
298+ environment_key = api_key ,
299+ enable_local_evaluation = False ,
300+ ** settings ,
301+ )
302+
303+ # When
304+ flagsmith .get_environment_flags ()
305+
306+ # Then
307+ session .get .assert_called_once_with (
308+ "https://edge.api.flagsmith.com/api/v1/flags/" ,
309+ json = None ,
310+ timeout = expected_timeout ,
311+ )
312+
313+
281314@responses .activate ()
282315def test_default_flag_is_used_when_no_environment_flags_returned (api_key : str ) -> None :
283316 # Given
You can’t perform that action at this time.
0 commit comments