(
mocker: MockFixture, config: BaseConfig, dry_run: bool, util: UtilFixture
)
| 251 | @pytest.mark.usefixtures("tmp_commitizen_project") |
| 252 | @pytest.mark.parametrize("dry_run", [True, False]) |
| 253 | def test_changelog_hook( |
| 254 | mocker: MockFixture, config: BaseConfig, dry_run: bool, util: UtilFixture |
| 255 | ): |
| 256 | changelog_hook_mock = mocker.Mock() |
| 257 | changelog_hook_mock.return_value = "cool changelog hook" |
| 258 | |
| 259 | util.create_file_and_commit("feat: new file") |
| 260 | util.create_file_and_commit("refactor: is in changelog") |
| 261 | util.create_file_and_commit("Merge into master") |
| 262 | |
| 263 | config.settings["change_type_order"] = ["Refactor", "Feat"] # type: ignore[typeddict-unknown-key] |
| 264 | changelog = Changelog( |
| 265 | config, {"unreleased_version": None, "incremental": True, "dry_run": dry_run} |
| 266 | ) |
| 267 | mocker.patch.object(changelog.cz, "changelog_hook", changelog_hook_mock) |
| 268 | if dry_run: |
| 269 | with pytest.raises(DryRunExit): |
| 270 | changelog() |
| 271 | else: |
| 272 | changelog() |
| 273 | |
| 274 | full_changelog = ( |
| 275 | "## Unreleased\n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n" |
| 276 | ) |
| 277 | partial_changelog = full_changelog |
| 278 | if dry_run: |
| 279 | partial_changelog = "" |
| 280 | |
| 281 | changelog_hook_mock.assert_called_with(full_changelog, partial_changelog) |
| 282 | |
| 283 | |
| 284 | @pytest.mark.usefixtures("tmp_commitizen_project") |
nothing calls this directly
no test coverage detected
searching dependent graphs…