コード例 #1
0
ファイル: test_law.py プロジェクト: kissmikijr/hammurabi
def test_commit_no_changes():
    rule = get_passing_rule()
    rule.execute = Mock()
    rule.made_changes = False

    law = Law(name="Passing", description="passing law", rules=(rule,))
    law.git_commit = Mock()
    law.get_execution_order = Mock(return_value=[rule])

    law.enforce()

    rule.execute.assert_called_once_with()
    assert law.git_commit.called is False
コード例 #2
0
ファイル: test_law.py プロジェクト: kissmikijr/hammurabi
def test_commit_changes():
    rule = get_passing_rule()
    rule.execute = Mock()
    rule.made_changes = True

    law = Law(name="Passing", description="passing law", rules=(rule,))
    law.git_commit = Mock()
    law.get_execution_order = Mock(return_value=[rule])

    expected_commit_message = f"{law.documentation}\n\n* {rule.name}"

    law.enforce()

    rule.execute.assert_called_once_with()
    law.get_execution_order.assert_called_once_with()
    law.git_commit.assert_called_once_with(expected_commit_message)