@@ -25,6 +25,25 @@ def test__get_project_for_url_or_path(mocker):
2525 assert project == _Project ()
2626
2727
28+ def test__get_project_for_url_or_path_generator_error (mocker ):
29+ data_dict = mocker .MagicMock ()
30+ _get_document = mocker .patch ("openapi_python_client._get_document" , return_value = data_dict )
31+ error = GeneratorError ()
32+ from_dict = mocker .patch ("openapi_python_client.parser.GeneratorData.from_dict" , return_value = error )
33+ _Project = mocker .patch ("openapi_python_client._Project" )
34+ url = mocker .MagicMock ()
35+ path = mocker .MagicMock ()
36+
37+ from openapi_python_client import _get_project_for_url_or_path
38+
39+ project = _get_project_for_url_or_path (url = url , path = path )
40+
41+ _get_document .assert_called_once_with (url = url , path = path )
42+ from_dict .assert_called_once_with (data_dict )
43+ _Project .assert_not_called ()
44+ assert project == error
45+
46+
2847def test_create_new_client (mocker ):
2948 project = mocker .MagicMock ()
3049 _get_project_for_url_or_path = mocker .patch (
@@ -35,10 +54,27 @@ def test_create_new_client(mocker):
3554
3655 from openapi_python_client import create_new_client
3756
38- create_new_client (url = url , path = path )
57+ result = create_new_client (url = url , path = path )
3958
4059 _get_project_for_url_or_path .assert_called_once_with (url = url , path = path )
4160 project .build .assert_called_once ()
61+ assert result == project .build .return_value
62+
63+
64+ def test_create_new_client_project_error (mocker ):
65+ error = GeneratorError ()
66+ _get_project_for_url_or_path = mocker .patch (
67+ "openapi_python_client._get_project_for_url_or_path" , return_value = error
68+ )
69+ url = mocker .MagicMock ()
70+ path = mocker .MagicMock ()
71+
72+ from openapi_python_client import create_new_client
73+
74+ result = create_new_client (url = url , path = path )
75+
76+ _get_project_for_url_or_path .assert_called_once_with (url = url , path = path )
77+ assert result == [error ]
4278
4379
4480def test_update_existing_client (mocker ):
@@ -51,10 +87,27 @@ def test_update_existing_client(mocker):
5187
5288 from openapi_python_client import update_existing_client
5389
54- update_existing_client (url = url , path = path )
90+ result = update_existing_client (url = url , path = path )
5591
5692 _get_project_for_url_or_path .assert_called_once_with (url = url , path = path )
5793 project .update .assert_called_once ()
94+ assert result == project .update .return_value
95+
96+
97+ def test_update_existing_client_project_error (mocker ):
98+ error = GeneratorError ()
99+ _get_project_for_url_or_path = mocker .patch (
100+ "openapi_python_client._get_project_for_url_or_path" , return_value = error
101+ )
102+ url = mocker .MagicMock ()
103+ path = mocker .MagicMock ()
104+
105+ from openapi_python_client import update_existing_client
106+
107+ result = update_existing_client (url = url , path = path )
108+
109+ _get_project_for_url_or_path .assert_called_once_with (url = url , path = path )
110+ assert result == [error ]
58111
59112
60113class TestGetJson :
0 commit comments