Skip to content

Commit fb888fe

Browse files
committed
test: add multiple test cases
1 parent 15e7176 commit fb888fe

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

tests/commands/test_commit_command.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
CommitError,
99
CustomError,
1010
DryRunExit,
11+
NoAnswersError,
1112
NoCommitBackupError,
1213
NothingToCommitError,
1314
)
@@ -140,3 +141,12 @@ def test_commit_when_non_customized_expected_raised(config, mocker, capsys):
140141
with pytest.raises(ValueError):
141142
commit_cmd = commands.Commit(config, {})
142143
commit_cmd()
144+
145+
146+
def test_commit_when_no_user_answer(config, mocker, capsys):
147+
prompt_mock = mocker.patch("questionary.prompt")
148+
prompt_mock.return_value = None
149+
150+
with pytest.raises(NoAnswersError):
151+
commit_cmd = commands.Commit(config, {})
152+
commit_cmd()

tests/test_cz_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ def test_info(config):
5151
cz = DummyCz(config)
5252
with pytest.raises(NotImplementedError):
5353
cz.info()
54+
55+
56+
def test_process_commit(config):
57+
cz = DummyCz(config)
58+
message = cz.process_commit("test(test_scope): this is test msg")
59+
assert message == "test(test_scope): this is test msg"

tests/test_cz_conventional_commits.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@ def test_info(config):
112112
conventional_commits = ConventionalCommitsCz(config)
113113
info = conventional_commits.info()
114114
assert isinstance(info, str)
115+
116+
def test_process_commit(config):
117+
conventional_commits = ConventionalCommitsCz(config)
118+
message = conventional_commits.process_commit("test(test_scope): this is test msg")
119+
assert message == "this is test msg"

tests/test_cz_customize.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,17 @@ def test_info_with_info_path(tmpdir):
136136
config = TomlConfig(data=toml_str, path="not_exist.toml")
137137
cz = CustomizeCommitsCz(config)
138138
assert "Test info" in cz.info()
139+
140+
141+
def test_info_without_info():
142+
toml_str = """
143+
[tool.commitizen.customize]
144+
message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif %}"
145+
example = "feature: this feature enable customize through config file"
146+
schema = "<type>: <body>"
147+
bump_pattern = "^(break|new|fix|hotfix)"
148+
bump_map = {"break" = "MAJOR", "new" = "MINOR", "fix" = "PATCH", "hotfix" = "PATCH"}
149+
"""
150+
config = TomlConfig(data=toml_str, path="not_exist.toml")
151+
cz = CustomizeCommitsCz(config)
152+
assert cz.info() is None

0 commit comments

Comments
 (0)