Example #1
0
def test_execute_skips_when_playbook_not_configured(
        patched_logger_warn, _patched_ansible_cleanup, config_instance):

    cu = cleanup.Cleanup(config_instance)
    cu.execute()

    msg = 'Skipping, cleanup playbook not configured.'
    patched_logger_warn.assert_called_once_with(msg)

    assert not _patched_ansible_cleanup.called
Example #2
0
def test_execute(mocker, _patched_ansible_cleanup, patched_logger_info,
                 patched_config_validate, config_instance):
    pb = os.path.join(config_instance.scenario.directory, 'cleanup.yml')
    util.write_file(pb, '')

    cu = cleanup.Cleanup(config_instance)
    cu.execute()

    x = [
        mocker.call("Scenario: 'default'"),
        mocker.call("Action: 'cleanup'"),
    ]
    assert x == patched_logger_info.mock_calls

    _patched_ansible_cleanup.assert_called_once_with()
Example #3
0
def test_execute(
    mocker,
    _patched_ansible_cleanup,
    patched_logger_info,
    patched_config_validate,
    config_instance,
):
    pb = os.path.join(config_instance.scenario.directory, "cleanup.yml")
    util.write_file(pb, "")

    cu = cleanup.Cleanup(config_instance)
    cu.execute()

    assert len(patched_logger_info.mock_calls) == 1
    name, args, kwargs = patched_logger_info.mock_calls[0]
    assert "cleanup" in args

    _patched_ansible_cleanup.assert_called_once_with()