Beispiel #1
0
def test_executed(name: str, param: Any, mocked_config):
    mocked_config.settings.dry_run = False

    rule = ExampleRule(name=name, param=param)

    rule.pre_task_hook = Mock()
    rule.post_task_hook = Mock()
    rule.task = Mock()

    rule.execute(param)

    rule.task.assert_called_once_with()
    rule.pre_task_hook.assert_called_once_with()
    rule.post_task_hook.assert_called_once_with()
Beispiel #2
0
def test_executed_no_direct_param(mocked_config):
    """
    This test case covers the situation of piped and child rules
    which has no direct parameter (it is set to None), but getting
    it from the output of the previous rule as an input.
    """

    mocked_config.settings.dry_run = False

    rule = ExampleRule(name="Test", param=None)
    rule.param = "Rule"

    rule.pre_task_hook = Mock()
    rule.post_task_hook = Mock()
    rule.task = Mock()

    rule.execute()

    rule.task.assert_called_once_with()
    rule.pre_task_hook.assert_called_once_with()
    rule.post_task_hook.assert_called_once_with()