(
mocker: MockFixture, config: BaseConfig, dry_run: bool, util: UtilFixture
)
| 292 | @pytest.mark.usefixtures("tmp_commitizen_project") |
| 293 | @pytest.mark.parametrize("dry_run", [True, False]) |
| 294 | def test_changelog_hook( |
| 295 | mocker: MockFixture, config: BaseConfig, dry_run: bool, util: UtilFixture |
| 296 | ): |
| 297 | changelog_hook_mock = mocker.Mock() |
| 298 | changelog_hook_mock.return_value = "cool changelog hook" |
| 299 | |
| 300 | util.create_file_and_commit("feat: new file") |
| 301 | util.create_file_and_commit("refactor: is in changelog") |
| 302 | util.create_file_and_commit("Merge into master") |
| 303 | |
| 304 | config.settings["change_type_order"] = ["Refactor", "Feat"] # type: ignore[typeddict-unknown-key] |
| 305 | changelog = Changelog( |
| 306 | config, {"unreleased_version": None, "incremental": True, "dry_run": dry_run} |
| 307 | ) |
| 308 | mocker.patch.object(changelog.cz, "changelog_hook", changelog_hook_mock) |
| 309 | if dry_run: |
| 310 | with pytest.raises(DryRunExit): |
| 311 | changelog() |
| 312 | else: |
| 313 | changelog() |
| 314 | |
| 315 | full_changelog = ( |
| 316 | "## Unreleased\n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n" |
| 317 | ) |
| 318 | partial_changelog = full_changelog |
| 319 | if dry_run: |
| 320 | partial_changelog = "" |
| 321 | |
| 322 | changelog_hook_mock.assert_called_with(full_changelog, partial_changelog) |
| 323 | |
| 324 | |
| 325 | @pytest.mark.usefixtures("tmp_commitizen_project") |
nothing calls this directly
no test coverage detected