diff --git a/tests/fixtures/example_project.py b/tests/fixtures/example_project.py index 7cc28872d..76e452a9f 100644 --- a/tests/fixtures/example_project.py +++ b/tests/fixtures/example_project.py @@ -14,7 +14,7 @@ ScipyCommitParser, TagCommitParser, ) -from semantic_release.hvcs import Gitea, Github, Gitlab +from semantic_release.hvcs import Gitea, Github, Gitlab, Bitbucket from tests.const import ( EXAMPLE_CHANGELOG_MD_CONTENT, @@ -352,3 +352,16 @@ def _use_gitea_hvcs(domain: str | None = None) -> type[HvcsBase]: return Gitea return _use_gitea_hvcs + + +@pytest.fixture(scope="session") +def use_bitbucket_hvcs(update_pyproject_toml: UpdatePyprojectTomlFn) -> UseHvcsFn: + """Modify the configuration file to use BitBucket as the HVCS.""" + + def _use_bitbucket_hvcs(domain: str | None = None) -> type[HvcsBase]: + update_pyproject_toml("tool.semantic_release.remote.type", "bitbucket") + if domain is not None: + update_pyproject_toml("tool.semantic_release.remote.domain", domain) + return Bitbucket + + return _use_bitbucket_hvcs diff --git a/tests/fixtures/git_repo.py b/tests/fixtures/git_repo.py index 4c5eba4fc..52274c867 100644 --- a/tests/fixtures/git_repo.py +++ b/tests/fixtures/git_repo.py @@ -252,6 +252,7 @@ def build_configured_base_repo( use_github_hvcs: UseHvcsFn, use_gitlab_hvcs: UseHvcsFn, use_gitea_hvcs: UseHvcsFn, + use_bitbucket_hvcs: UseHvcsFn, use_angular_parser: UseParserFn, use_emoji_parser: UseParserFn, use_scipy_parser: UseParserFn, @@ -301,6 +302,8 @@ def _build_configured_base_repo( hvcs_class = use_gitlab_hvcs(hvcs_domain) elif hvcs_client_name == "gitea": hvcs_class = use_gitea_hvcs(hvcs_domain) + elif hvcs_client_name == "bitbucket": + hvcs_class = use_bitbucket_hvcs(hvcs_domain) else: raise ValueError(f"Unknown HVCS client name: {hvcs_client_name}") diff --git a/tests/unit/semantic_release/changelog/test_default_changelog.py b/tests/unit/semantic_release/changelog/test_default_changelog.py index cc138b0de..53dd886c6 100644 --- a/tests/unit/semantic_release/changelog/test_default_changelog.py +++ b/tests/unit/semantic_release/changelog/test_default_changelog.py @@ -16,7 +16,7 @@ from semantic_release.changelog.template import environment from semantic_release.commit_parser import ParsedCommit from semantic_release.enums import LevelBump -from semantic_release.hvcs import Gitea, Github, Gitlab +from semantic_release.hvcs import Gitea, Github, Gitlab, Bitbucket from semantic_release.version.translator import Version from tests.const import TODAY_DATE_STR @@ -92,7 +92,7 @@ def artificial_release_history(commit_author: Actor): ) -@pytest.mark.parametrize("hvcs_client", [Github, Gitlab, Gitea]) +@pytest.mark.parametrize("hvcs_client", [Github, Gitlab, Gitea, Bitbucket]) def test_default_changelog_template( default_changelog_template: str, hvcs_client: type[HvcsBase], @@ -106,11 +106,11 @@ def test_default_changelog_template( feat_commit_obj = artificial_release_history.released[version]["elements"]["feature"][0] feat_commit_url = hvcs_client(example_git_https_url).commit_hash_url(feat_commit_obj.commit.hexsha) - feat_description = str.join('\n', feat_commit_obj.descriptions) + feat_description = str.join('\n', feat_commit_obj.descriptions) # type: ignore fix_commit_obj = artificial_release_history.released[version]["elements"]["fix"][0] fix_commit_url = hvcs_client(example_git_https_url).commit_hash_url(fix_commit_obj.commit.hexsha) - fix_description = str.join('\n', fix_commit_obj.descriptions) + fix_description = str.join('\n', fix_commit_obj.descriptions) # type: ignore expected_changelog = str.join("\n", [ "# CHANGELOG", @@ -131,7 +131,7 @@ def test_default_changelog_template( assert expected_changelog == actual_changelog -@pytest.mark.parametrize("hvcs_client", [Github, Gitlab, Gitea]) +@pytest.mark.parametrize("hvcs_client", [Github, Gitlab, Gitea, Bitbucket]) def test_default_changelog_template_w_unreleased_changes( default_changelog_template: str, hvcs_client: type[HvcsBase], @@ -143,11 +143,11 @@ def test_default_changelog_template_w_unreleased_changes( feat_commit_obj = artificial_release_history.released[version]["elements"]["feature"][0] feat_commit_url = hvcs_client(example_git_https_url).commit_hash_url(feat_commit_obj.commit.hexsha) - feat_description = str.join('\n', feat_commit_obj.descriptions) + feat_description = str.join('\n', feat_commit_obj.descriptions) # type: ignore fix_commit_obj = artificial_release_history.released[version]["elements"]["fix"][0] fix_commit_url = hvcs_client(example_git_https_url).commit_hash_url(fix_commit_obj.commit.hexsha) - fix_description = str.join('\n', fix_commit_obj.descriptions) + fix_description = str.join('\n', fix_commit_obj.descriptions) # type: ignore expected_changelog = str.join("\n", [ "# CHANGELOG", diff --git a/tests/unit/semantic_release/changelog/test_release_notes.py b/tests/unit/semantic_release/changelog/test_release_notes.py index cd2adf0e9..fe297cdd8 100644 --- a/tests/unit/semantic_release/changelog/test_release_notes.py +++ b/tests/unit/semantic_release/changelog/test_release_notes.py @@ -17,7 +17,7 @@ from semantic_release.changelog.template import environment from semantic_release.commit_parser import ParsedCommit from semantic_release.enums import LevelBump -from semantic_release.hvcs import Gitea, Github, Gitlab +from semantic_release.hvcs import Gitea, Github, Gitlab, Bitbucket from semantic_release.version import Version from tests.const import TODAY_DATE_STR @@ -72,7 +72,7 @@ def release_notes_template() -> str: return version_notes_template.read_text(encoding="utf-8") -@pytest.mark.parametrize("hvcs_client", [Github, Gitlab, Gitea]) +@pytest.mark.parametrize("hvcs_client", [Github, Gitlab, Gitea, Bitbucket]) def test_default_release_notes_template( example_git_https_url: str, hvcs_client: type[HvcsBase], @@ -88,7 +88,7 @@ def test_default_release_notes_template( version = Version.parse(version_str) commit_obj = artificial_release_history.released[version]["elements"]["fix"][0] commit_url = hvcs_client(example_git_https_url).commit_hash_url(commit_obj.commit.hexsha) - commit_description = str.join('\n', commit_obj.descriptions) + commit_description = str.join('\n', commit_obj.descriptions) # type: ignore expected_content = str.join("\n", [ f"# v{version_str} ({TODAY_DATE_STR})", "## Fix",