@@ -343,55 +343,82 @@ def test__build_api(self, mocker):
343343 openapi .endpoint_collections_by_tag = {tag_1 : collection_1 , tag_2 : collection_2 }
344344 project = _Project (openapi = openapi )
345345 project .package_dir = mocker .MagicMock ()
346+ api_errors = mocker .MagicMock (autospec = pathlib .Path )
346347 client_path = mocker .MagicMock ()
347348 api_init = mocker .MagicMock (autospec = pathlib .Path )
348- api_errors = mocker .MagicMock (autospec = pathlib .Path )
349349 collection_1_path = mocker .MagicMock (autospec = pathlib .Path )
350350 collection_2_path = mocker .MagicMock (autospec = pathlib .Path )
351+ async_api_init = mocker .MagicMock (autospec = pathlib .Path )
352+ async_collection_1_path = mocker .MagicMock (autospec = pathlib .Path )
353+ async_collection_2_path = mocker .MagicMock (autospec = pathlib .Path )
351354 api_paths = {
352355 "__init__.py" : api_init ,
353- "errors.py" : api_errors ,
354356 f"{ tag_1 } .py" : collection_1_path ,
355357 f"{ tag_2 } .py" : collection_2_path ,
356358 }
359+ async_api_paths = {
360+ "__init__.py" : async_api_init ,
361+ f"{ tag_1 } .py" : async_collection_1_path ,
362+ f"{ tag_2 } .py" : async_collection_2_path ,
363+ }
357364 api_dir = mocker .MagicMock (autospec = pathlib .Path )
358365 api_dir .__truediv__ .side_effect = lambda x : api_paths [x ]
366+ async_api_dir = mocker .MagicMock (autospec = pathlib .Path )
367+ async_api_dir .__truediv__ .side_effect = lambda x : async_api_paths [x ]
368+
359369 package_paths = {
360370 "client.py" : client_path ,
361371 "api" : api_dir ,
372+ "async_api" : async_api_dir ,
373+ "errors.py" : api_errors ,
362374 }
363375 project .package_dir .__truediv__ .side_effect = lambda x : package_paths [x ]
364376 client_template = mocker .MagicMock (autospec = Template )
365377 errors_template = mocker .MagicMock (autospec = Template )
366378 endpoint_template = mocker .MagicMock (autospec = Template )
379+ async_endpoint_template = mocker .MagicMock (autospec = Template )
367380 templates = {
368381 "client.pyi" : client_template ,
369382 "errors.pyi" : errors_template ,
370383 "endpoint_module.pyi" : endpoint_template ,
384+ "async_endpoint_module.pyi" : async_endpoint_template ,
371385 }
372386 mocker .patch .object (project .env , "get_template" , autospec = True , side_effect = lambda x : templates [x ])
373387 endpoint_renders = {
374388 collection_1 : mocker .MagicMock (),
375389 collection_2 : mocker .MagicMock (),
376390 }
377391 endpoint_template .render .side_effect = lambda collection : endpoint_renders [collection ]
392+ async_endpoint_renders = {
393+ collection_1 : mocker .MagicMock (),
394+ collection_2 : mocker .MagicMock (),
395+ }
396+ async_endpoint_template .render .side_effect = lambda collection : async_endpoint_renders [collection ]
378397
379398 project ._build_api ()
380399
381400 project .package_dir .__truediv__ .assert_has_calls ([mocker .call (key ) for key in package_paths ])
382401 project .env .get_template .assert_has_calls ([mocker .call (key ) for key in templates ])
383402 client_template .render .assert_called_once ()
384403 client_path .write_text .assert_called_once_with (client_template .render ())
385- api_dir .mkdir .assert_called_once ()
386- api_dir .__truediv__ .assert_has_calls ([mocker .call (key ) for key in api_paths ])
387- api_init .write_text .assert_called_once_with ('""" Contains all methods for accessing the API """' )
388404 errors_template .render .assert_called_once ()
389405 api_errors .write_text .assert_called_once_with (errors_template .render ())
406+ api_dir .mkdir .assert_called_once ()
407+ api_dir .__truediv__ .assert_has_calls ([mocker .call (key ) for key in api_paths ])
408+ api_init .write_text .assert_called_once_with ('""" Contains synchronous methods for accessing the API """' )
390409 endpoint_template .render .assert_has_calls (
391410 [mocker .call (collection = collection_1 ), mocker .call (collection = collection_2 )]
392411 )
393412 collection_1_path .write_text .assert_called_once_with (endpoint_renders [collection_1 ])
394413 collection_2_path .write_text .assert_called_once_with (endpoint_renders [collection_2 ])
414+ async_api_dir .mkdir .assert_called_once ()
415+ async_api_dir .__truediv__ .assert_has_calls ([mocker .call (key ) for key in async_api_paths ])
416+ async_api_init .write_text .assert_called_once_with ('""" Contains async methods for accessing the API """' )
417+ async_endpoint_template .render .assert_has_calls (
418+ [mocker .call (collection = collection_1 ), mocker .call (collection = collection_2 )]
419+ )
420+ async_collection_1_path .write_text .assert_called_once_with (async_endpoint_renders [collection_1 ])
421+ async_collection_2_path .write_text .assert_called_once_with (async_endpoint_renders [collection_2 ])
395422
396423
397424def test__reformat (mocker ):
0 commit comments