def test__build_setup_py(self, mocker):
        from openapi_python_client import MetaType, Project

        project = Project(openapi=mocker.MagicMock(title="My Test API"),
                          meta=MetaType.SETUP)
        project.project_dir = mocker.MagicMock()
        setup_path = mocker.MagicMock(autospec=pathlib.Path)
        paths = {
            "setup.py": setup_path,
        }
        project.project_dir.__truediv__.side_effect = lambda x: paths[x]

        setup_template = mocker.MagicMock(autospec=jinja2.Template)
        project.env = mocker.MagicMock(autospec=jinja2.Environment)
        templates = {
            "setup.py.jinja": setup_template,
        }
        project.env.get_template.side_effect = lambda x: templates[x]

        project._build_setup_py()

        project.env.get_template.assert_called_once_with("setup.py.jinja")

        setup_template.render.assert_called_once_with(
            project_name=project.project_name,
            package_name=project.package_name,
            version=project.version,
            description=project.package_description,
        )
        setup_path.write_text.assert_called_once_with(setup_template.render(),
                                                      encoding="utf-8")
    def test__build_metadata_setup(self, mocker):
        from openapi_python_client import MetaType, Project

        project = Project(openapi=mocker.MagicMock(title="My Test API"),
                          meta=MetaType.SETUP)
        project._build_pyproject_toml = mocker.MagicMock()
        project._build_setup_py = mocker.MagicMock()
        project.project_dir = mocker.MagicMock()
        readme_path = mocker.MagicMock(autospec=pathlib.Path)
        git_ignore_path = mocker.MagicMock(autospec=pathlib.Path)
        paths = {
            "README.md": readme_path,
            ".gitignore": git_ignore_path,
        }
        project.project_dir.__truediv__.side_effect = lambda x: paths[x]

        readme_template = mocker.MagicMock(autospec=jinja2.Template)
        git_ignore_template = mocker.MagicMock(autospec=jinja2.Template)
        project.env = mocker.MagicMock(autospec=jinja2.Environment)
        templates = {
            "README.md.jinja": readme_template,
            ".gitignore.jinja": git_ignore_template,
        }
        project.env.get_template.side_effect = lambda x: templates[x]

        project._build_metadata()

        project.env.get_template.assert_has_calls(
            [mocker.call("README.md.jinja"),
             mocker.call(".gitignore.jinja")])
        readme_template.render.assert_called_once_with(
            description=project.package_description,
            project_name=project.project_name,
            package_name=project.package_name,
        )
        readme_path.write_text.assert_called_once_with(
            readme_template.render(), encoding="utf-8")
        git_ignore_template.render.assert_called_once()
        git_ignore_path.write_text.assert_called_once_with(
            git_ignore_template.render(), encoding="utf-8")
        project._build_pyproject_toml.assert_called_once_with(use_poetry=False)
        project._build_setup_py.assert_called_once()