@@ -244,23 +244,27 @@ def test_execute_retries(mocked_responses):
244244 assert results == expected
245245
246246
247- def test_execute_max_retries_exceeded (mocked_responses ):
247+ @pytest .mark .parametrize (
248+ 'code' ,
249+ [500 , 501 , 502 ],
250+ )
251+ def test_execute_max_retries_exceeded (code , mocked_responses ):
248252 mocked_responses .add (
249253 responses .GET ,
250254 'https://localhost/resources' ,
251- status = 502 ,
255+ status = code ,
252256 )
253257
254258 mocked_responses .add (
255259 responses .GET ,
256260 'https://localhost/resources' ,
257- status = 502 ,
261+ status = code ,
258262 )
259263
260264 mocked_responses .add (
261265 responses .GET ,
262266 'https://localhost/resources' ,
263- status = 502 ,
267+ status = code ,
264268 )
265269
266270 c = ConnectClient (
@@ -323,6 +327,57 @@ def test_execute_with_kwargs(mocked_responses):
323327 assert 'X-Custom-Header' in headers and headers ['X-Custom-Header' ] == 'value'
324328
325329
330+ def test_execute_with_overwritten_timeout (mocked_responses , mocker ):
331+ http_call = mocker .patch (
332+ 'connect.client.mixins.SyncClientMixin._execute_http_call' ,
333+ side_effect = RequestException (),
334+ )
335+
336+ c = ConnectClient ('API_KEY' , endpoint = 'https://localhost' , use_specs = False )
337+ kwargs = {
338+ 'timeout' : 500 ,
339+ }
340+
341+ with pytest .raises (ClientError ):
342+ c .execute ('post' , 'resources' , ** kwargs )
343+
344+ http_call .assert_called_with (
345+ 'post' ,
346+ 'https://localhost/resources' ,
347+ {
348+ 'timeout' : 500 ,
349+ 'headers' : {
350+ 'Authorization' : 'API_KEY' ,
351+ 'User-Agent' : mocker .ANY ,
352+ },
353+ },
354+ )
355+
356+
357+ def test_execute_with_default_timeout (mocked_responses , mocker ):
358+ http_call = mocker .patch (
359+ 'connect.client.mixins.SyncClientMixin._execute_http_call' ,
360+ side_effect = RequestException (),
361+ )
362+
363+ c = ConnectClient ('API_KEY' , endpoint = 'https://localhost' , use_specs = False )
364+
365+ with pytest .raises (ClientError ):
366+ c .execute ('post' , 'resources' )
367+
368+ http_call .assert_called_with (
369+ 'post' ,
370+ 'https://localhost/resources' ,
371+ {
372+ 'timeout' : (180.0 , 180.0 ),
373+ 'headers' : {
374+ 'Authorization' : 'API_KEY' ,
375+ 'User-Agent' : mocker .ANY ,
376+ },
377+ },
378+ )
379+
380+
326381def test_execute_connect_error (mocked_responses ):
327382 connect_error = {
328383 'error_code' : 'code' ,
0 commit comments