def test_build_no_meta(self, mocker): from openapi_python_client import MetaType, Project project = Project(openapi=mocker.MagicMock(title="My Test API"), meta=MetaType.NONE) project.project_dir = mocker.MagicMock() project.package_dir = mocker.MagicMock() project._build_metadata = mocker.MagicMock() project._build_models = mocker.MagicMock() project._build_api = mocker.MagicMock() project._create_package = mocker.MagicMock() project._reformat = mocker.MagicMock() project._get_errors = mocker.MagicMock() project.build() project.project_dir.mkdir.assert_not_called()
def test_build_file_exists(self, mocker): from openapi_python_client import Project project = Project(openapi=mocker.MagicMock(title="My Test API")) project.project_dir = mocker.MagicMock() project.project_dir.mkdir.side_effect = FileExistsError result = project.build() project.project_dir.mkdir.assert_called_once() assert result == [ GeneratorError( detail= "Directory already exists. Delete it or use the update command." ) ]
def test_build(self, mocker): from openapi_python_client import Project project = Project(openapi=mocker.MagicMock(title="My Test API")) project.project_dir = mocker.MagicMock() project.package_dir = mocker.MagicMock() project._build_metadata = mocker.MagicMock() project._build_models = mocker.MagicMock() project._build_api = mocker.MagicMock() project._create_package = mocker.MagicMock() project._reformat = mocker.MagicMock() project._get_errors = mocker.MagicMock() result = project.build() project.project_dir.mkdir.assert_called_once() project._create_package.assert_called_once() project._build_metadata.assert_called_once() project._build_models.assert_called_once() project._build_api.assert_called_once() project._reformat.assert_called_once() project._get_errors.assert_called_once() assert result == project._get_errors.return_value