77
88from openapi_python_client import Config , ErrorLevel , GeneratorError , Project
99
10+ default_http_timeout = Config .schema ()["properties" ]["http_timeout" ]["default" ]
11+
1012
1113def test__get_project_for_url_or_path (mocker ):
1214 data_dict = mocker .MagicMock ()
@@ -17,12 +19,13 @@ def test__get_project_for_url_or_path(mocker):
1719 url = mocker .MagicMock ()
1820 path = mocker .MagicMock ()
1921 config = mocker .MagicMock ()
22+ config .http_timeout = default_http_timeout
2023
2124 from openapi_python_client import MetaType , _get_project_for_url_or_path
2225
2326 project = _get_project_for_url_or_path (url = url , path = path , meta = MetaType .POETRY , config = config )
2427
25- _get_document .assert_called_once_with (url = url , path = path )
28+ _get_document .assert_called_once_with (url = url , path = path , timeout = default_http_timeout )
2629 from_dict .assert_called_once_with (data_dict , config = config )
2730 _Project .assert_called_once_with (
2831 openapi = openapi , custom_template_path = None , meta = MetaType .POETRY , file_encoding = "utf-8" , config = config
@@ -39,12 +42,13 @@ def test__get_project_for_url_or_path_generator_error(mocker):
3942 url = mocker .MagicMock ()
4043 path = mocker .MagicMock ()
4144 config = mocker .MagicMock ()
45+ config .http_timeout = default_http_timeout
4246
4347 from openapi_python_client import MetaType , _get_project_for_url_or_path
4448
4549 project = _get_project_for_url_or_path (url = url , path = path , meta = MetaType .POETRY , config = config )
4650
47- _get_document .assert_called_once_with (url = url , path = path )
51+ _get_document .assert_called_once_with (url = url , path = path , timeout = default_http_timeout )
4852 from_dict .assert_called_once_with (data_dict , config = config )
4953 _Project .assert_not_called ()
5054 assert project == error
@@ -62,7 +66,7 @@ def test__get_project_for_url_or_path_document_error(mocker):
6266
6367 project = _get_project_for_url_or_path (url = url , path = path , meta = MetaType .POETRY , config = Config ())
6468
65- _get_document .assert_called_once_with (url = url , path = path )
69+ _get_document .assert_called_once_with (url = url , path = path , timeout = default_http_timeout )
6670 from_dict .assert_not_called ()
6771 assert project == error
6872
@@ -153,7 +157,7 @@ def test__get_document_no_url_or_path(self, mocker):
153157
154158 from openapi_python_client import _get_document
155159
156- result = _get_document (url = None , path = None )
160+ result = _get_document (url = None , path = None , timeout = default_http_timeout )
157161
158162 assert result == GeneratorError (header = "No URL or Path provided" )
159163 get .assert_not_called ()
@@ -167,7 +171,7 @@ def test__get_document_url_and_path(self, mocker):
167171
168172 from openapi_python_client import _get_document
169173
170- result = _get_document (url = mocker .MagicMock (), path = mocker .MagicMock ())
174+ result = _get_document (url = mocker .MagicMock (), path = mocker .MagicMock (), timeout = default_http_timeout )
171175
172176 assert result == GeneratorError (header = "Provide URL or Path, not both." )
173177 get .assert_not_called ()
@@ -182,10 +186,10 @@ def test__get_document_bad_url(self, mocker):
182186 from openapi_python_client import _get_document
183187
184188 url = mocker .MagicMock ()
185- result = _get_document (url = url , path = None )
189+ result = _get_document (url = url , path = None , timeout = default_http_timeout )
186190
187191 assert result == GeneratorError (header = "Could not get OpenAPI document from provided URL" )
188- get .assert_called_once_with (url )
192+ get .assert_called_once_with (url , timeout = default_http_timeout )
189193 _Path .assert_not_called ()
190194 loads .assert_not_called ()
191195
@@ -197,9 +201,9 @@ def test__get_document_url_no_path(self, mocker):
197201 from openapi_python_client import _get_document
198202
199203 url = "test"
200- _get_document (url = url , path = None )
204+ _get_document (url = url , path = None , timeout = default_http_timeout )
201205
202- get .assert_called_once_with (url )
206+ get .assert_called_once_with (url , timeout = default_http_timeout )
203207 _Path .assert_not_called ()
204208 loads .assert_called_once_with (get ().content )
205209
@@ -211,7 +215,7 @@ def test__get_document_path_no_url(self, tmp_path, mocker):
211215
212216 from openapi_python_client import _get_document
213217
214- _get_document (url = None , path = path )
218+ _get_document (url = None , path = path , timeout = default_http_timeout )
215219
216220 get .assert_not_called ()
217221 loads .assert_called_once_with (b"some test data" )
@@ -222,7 +226,7 @@ def test__get_document_bad_yaml(self, mocker, tmp_path):
222226
223227 path = tmp_path / "test.yaml"
224228 path .write_text ("'" )
225- result = _get_document (url = None , path = path )
229+ result = _get_document (url = None , path = path , timeout = default_http_timeout )
226230
227231 get .assert_not_called ()
228232 assert isinstance (result , GeneratorError )
@@ -241,7 +245,7 @@ class FakeResponse:
241245 from openapi_python_client import _get_document
242246
243247 url = mocker .MagicMock ()
244- result = _get_document (url = url , path = None )
248+ result = _get_document (url = url , path = None , timeout = default_http_timeout )
245249
246250 get .assert_called_once ()
247251 json_loads .assert_called_once_with (FakeResponse .content .decode ())
@@ -258,7 +262,7 @@ class FakeResponse:
258262 from openapi_python_client import _get_document
259263
260264 url = mocker .MagicMock ()
261- result = _get_document (url = url , path = None )
265+ result = _get_document (url = url , path = None , timeout = default_http_timeout )
262266
263267 get .assert_called_once ()
264268 assert result == GeneratorError (
0 commit comments