@@ -220,6 +220,7 @@ def test__build_models(self, mocker):
220220
221221 def test__build_api (self , mocker ):
222222 import pathlib
223+ from jinja2 import Template
223224 from openapi_python_client import _Project , OpenAPI
224225
225226 openapi = mocker .MagicMock (autospec = OpenAPI , title = "My Test API" )
@@ -232,10 +233,12 @@ def test__build_api(self, mocker):
232233 project .package_dir = mocker .MagicMock ()
233234 client_path = mocker .MagicMock ()
234235 api_init = mocker .MagicMock (autospec = pathlib .Path )
236+ api_errors = mocker .MagicMock (autospec = pathlib .Path )
235237 collection_1_path = mocker .MagicMock (autospec = pathlib .Path )
236238 collection_2_path = mocker .MagicMock (autospec = pathlib .Path )
237239 api_paths = {
238240 "__init__.py" : api_init ,
241+ "errors.py" : api_errors ,
239242 f"{ tag_1 } .py" : collection_1_path ,
240243 f"{ tag_2 } .py" : collection_2_path ,
241244 }
@@ -246,10 +249,12 @@ def test__build_api(self, mocker):
246249 "api" : api_dir ,
247250 }
248251 project .package_dir .__truediv__ .side_effect = lambda x : package_paths [x ]
249- client_template = mocker .MagicMock ()
250- endpoint_template = mocker .MagicMock ()
252+ client_template = mocker .MagicMock (autospec = Template )
253+ errors_template = mocker .MagicMock (autospec = Template )
254+ endpoint_template = mocker .MagicMock (autospec = Template )
251255 templates = {
252256 "client.pyi" : client_template ,
257+ "errors.pyi" : errors_template ,
253258 "endpoint_module.pyi" : endpoint_template ,
254259 }
255260 mocker .patch .object (project .env , "get_template" , autospec = True , side_effect = lambda x : templates [x ])
@@ -268,6 +273,8 @@ def test__build_api(self, mocker):
268273 api_dir .mkdir .assert_called_once ()
269274 api_dir .__truediv__ .assert_has_calls ([mocker .call (key ) for key in api_paths ])
270275 api_init .write_text .assert_called_once_with ('""" Contains all methods for accessing the API """' )
276+ errors_template .render .assert_called_once ()
277+ api_errors .write_text .assert_called_once_with (errors_template .render ())
271278 endpoint_template .render .assert_has_calls (
272279 [mocker .call (collection = collection_1 ), mocker .call (collection = collection_2 ),]
273280 )
0 commit comments