File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717"""Tests for client behavior when issuing requests."""
1818
19+ import httpx
1920import pytest
2021
2122from ... import _api_client
@@ -180,3 +181,33 @@ def test_base_url_resource_scope_not_set_by_default():
180181def test_retry_options_not_set_by_default ():
181182 options = types .HttpOptions ()
182183 assert options .retry_options is None
184+
185+
186+ def test_default_timeout_is_none_for_httpx_and_request ():
187+ api_client = _api_client .BaseApiClient (
188+ vertexai = False ,
189+ api_key = 'test_api_key' ,
190+ )
191+ assert api_client ._httpx_client .timeout == httpx .Timeout (None )
192+ assert api_client ._async_httpx_client .timeout == httpx .Timeout (None )
193+ request = api_client ._build_request (
194+ http_method = 'POST' ,
195+ path = 'sample/path' ,
196+ request_dict = {},
197+ )
198+ assert request .timeout is None
199+
200+
201+ def test_setting_30m_timeout_populates_header_and_request_timeout ():
202+ api_client = _api_client .BaseApiClient (
203+ vertexai = False ,
204+ api_key = 'test_api_key' ,
205+ http_options = types .HttpOptions (timeout = 1800000 ),
206+ )
207+ request = api_client ._build_request (
208+ http_method = 'POST' ,
209+ path = 'sample/path' ,
210+ request_dict = {},
211+ )
212+ assert request .headers ['X-Server-Timeout' ] == '1800'
213+ assert request .timeout == 1800.0
Original file line number Diff line number Diff line change @@ -231,3 +231,11 @@ def test_interaction_lenient_parsing():
231231 assert isinstance (parsed , gaos_interaction .Interaction )
232232 assert parsed .id == "x"
233233
234+
235+ def test_interactions_default_timeout ():
236+ from ... import _interactions
237+
238+ assert _interactions .DEFAULT_TIMEOUT == httpx .Timeout (
239+ timeout = None , connect = 5.0
240+ )
241+
You can’t perform that action at this time.
0 commit comments