File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Expand file tree Collapse file tree 2 files changed +31
-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,36 @@ def test_non_200_response_raises_flagsmith_api_error(flagsmith: Flagsmith) -> No
278278 # expected exception raised
279279
280280
281+ @pytest .mark .parametrize ('settings, expected_timeout' , [
282+ ({'request_timeout_seconds' : 5 }, 5 ), # Arbitrary timeout
283+ ({'request_timeout_seconds' : None }, None ), # No timeout is forced
284+ ({}, 10 ), # Default timeout
285+ ])
286+ def test_request_times_out_according_to_setting (
287+ mocker : MockerFixture ,
288+ api_key : str ,
289+ settings : dict ,
290+ expected_timeout : int | None ,
291+ ):
292+ # Given
293+ session = mocker .patch ("flagsmith.flagsmith.requests.Session" ).return_value
294+ flagsmith = Flagsmith (
295+ environment_key = api_key ,
296+ enable_local_evaluation = False ,
297+ ** settings ,
298+ )
299+
300+ # When
301+ flagsmith .get_environment_flags ()
302+
303+ # Then
304+ session .get .assert_called_once_with (
305+ 'https://edge.api.flagsmith.com/api/v1/flags/' ,
306+ json = None ,
307+ timeout = expected_timeout ,
308+ )
309+
310+
281311@responses .activate ()
282312def test_default_flag_is_used_when_no_environment_flags_returned (api_key : str ) -> None :
283313 # Given
You can’t perform that action at this time.
0 commit comments