def test_update_missing_dir(self, mocker): from openapi_python_client import Project project = Project(openapi=mocker.MagicMock(title="My Test API")) project.package_dir = mocker.MagicMock() project.package_dir.is_dir.return_value = False project._build_models = mocker.MagicMock() with pytest.raises(FileNotFoundError): project.update() project.package_dir.is_dir.assert_called_once() project._build_models.assert_not_called()
def test_update(self, mocker): from openapi_python_client import Project, shutil rmtree = mocker.patch.object(shutil, "rmtree") project = Project(openapi=mocker.MagicMock(title="My Test API")) 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.update() rmtree.assert_called_once_with(project.package_dir) project._create_package.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