File: test_cz_utils.py

package info (click to toggle)
commitizen 4.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,672 kB
  • sloc: python: 14,530; makefile: 15
file content (26 lines) | stat: -rw-r--r-- 873 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pytest
from pytest_mock import MockFixture

from commitizen.cz import exceptions, utils


def test_required_validator():
    assert utils.required_validator("test") == "test"

    with pytest.raises(exceptions.AnswerRequiredError):
        utils.required_validator("")


def test_multiple_line_breaker():
    message = "this is the first line    | and this is the second line   "
    result = utils.multiple_line_breaker(message)
    assert result == "this is the first line\nand this is the second line"

    result = utils.multiple_line_breaker(message, "is")
    assert result == "th\n\nthe first line    | and th\n\nthe second line"


def test_get_backup_file_path_no_project_root(mocker: MockFixture):
    project_root_mock = mocker.patch("commitizen.git.find_git_project_root")
    project_root_mock.return_value = None
    assert utils.get_backup_file_path()