Debian Codegraph @

tests/test_cz_utils.py

raw
1 import pytest
2 from pytest_mock import MockFixture
3
4 from commitizen.cz import exceptions, utils
5
6
7 def test_required_validator():
8 assert utils.required_validator("test") == "test"
9
10 with pytest.raises(exceptions.AnswerRequiredError):
11 utils.required_validator("")
12
13
14 def test_multiple_line_breaker():
15 message = "this is the first line | and this is the second line "
16 result = utils.multiple_line_breaker(message)
17 assert result == "this is the first line\nand this is the second line"
18
19 result = utils.multiple_line_breaker(message, "is")
20 assert result == "th\n\nthe first line | and th\n\nthe second line"
21
22
23 def test_get_backup_file_path_no_project_root(mocker: MockFixture):
24 project_root_mock = mocker.patch("commitizen.git.find_git_project_root")
25 project_root_mock.return_value = None
26 assert utils.get_backup_file_path()