|
2 | 2 |
|
3 | 3 | import pytest
|
4 | 4 | from pytest_mock import MockFixture
|
| 5 | +from unittest.mock import ANY |
5 | 6 |
|
6 | 7 | from commitizen import cmd, commands
|
7 | 8 | from commitizen.cz.exceptions import CzException
|
@@ -172,6 +173,31 @@ def test_commit_command_with_signoff_option(config, mocker: MockFixture):
|
172 | 173 | success_mock = mocker.patch("commitizen.out.success")
|
173 | 174 |
|
174 | 175 | commands.Commit(config, {"signoff": True})()
|
| 176 | + |
| 177 | + commit_mock.assert_called_once_with(ANY, "-s") |
| 178 | + success_mock.assert_called_once() |
| 179 | + |
| 180 | + |
| 181 | +@pytest.mark.usefixtures("staging_is_clean") |
| 182 | +def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture): |
| 183 | + prompt_mock = mocker.patch("questionary.prompt") |
| 184 | + prompt_mock.return_value = { |
| 185 | + "prefix": "feat", |
| 186 | + "subject": "user created", |
| 187 | + "scope": "", |
| 188 | + "is_breaking_change": False, |
| 189 | + "body": "", |
| 190 | + "footer": "", |
| 191 | + } |
| 192 | + |
| 193 | + commit_mock = mocker.patch("commitizen.git.commit") |
| 194 | + commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) |
| 195 | + success_mock = mocker.patch("commitizen.out.success") |
| 196 | + |
| 197 | + config.settings["always_signoff"] = True |
| 198 | + commands.Commit(config, {})() |
| 199 | + |
| 200 | + commit_mock.assert_called_once_with(ANY, "-s") |
175 | 201 | success_mock.assert_called_once()
|
176 | 202 |
|
177 | 203 |
|
|
0 commit comments