Example #1
0
def test_ansiblelint_ok(temp_root):
    with open(get_ansiblelint_filename(temp_root), 'w') as fp:
        fp.write(ANSIBLELINT_TEST_FILE_OK)
        fp.flush()

        linter = linters.AnsibleLinter()
        linter.root = get_ansiblelint_root(temp_root)
        result = list(linter.check_files(['.']))
    assert result == []
Example #2
0
def test_ansiblelint_fail_app(temp_root):
    with open(get_ansiblelint_filename(temp_root), 'w') as fp:
        fp.write(ANSIBLELINT_TEST_FILE_FAIL_APP)
        fp.flush()

        linter = linters.AnsibleLinter()
        linter.root = get_ansiblelint_root(temp_root)
        result = list(linter.check_files(['.']))
        expected = 'exception running ansible-lint'
    assert expected in ' '.join(result).lower()
Example #3
0
def test_ansiblelint_fail(temp_root):
    with open(get_ansiblelint_filename(temp_root), 'w') as fp:
        fp.write(ANSIBLELINT_TEST_FILE_FAIL)
        fp.flush()

        linter = linters.AnsibleLinter()
        linter.root = get_ansiblelint_root(temp_root)
        result = list(linter.check_files(['.']))
        expected = 'deprecated sudo'
    assert expected in ' '.join(result).lower()
Example #4
0
def test_ansiblelint_fail(temp_root):
    with open(get_ansiblelint_filename(temp_root), 'w') as fp:
        fp.write(ANSIBLELINT_TASK_WARN)
        fp.flush()

        linter = linters.AnsibleLinter()
        linter.root = get_ansiblelint_root(temp_root)
        result = list(linter.check_files(['.']))
        expected = 'variables should have spaces before and after'
    assert expected in ' '.join(result).lower()