File: test_import_tasks.py

package info (click to toggle)
ansible-lint 25.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,660 kB
  • sloc: python: 19,201; sh: 70; makefile: 7
file content (34 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
"""Test related to import of invalid files."""

import pytest

from ansiblelint.rules import RulesCollection
from ansiblelint.runner import Runner


@pytest.mark.parametrize(
    ("playbook_path", "lintable_count", "match_count"),
    (
        pytest.param(
            "examples/playbooks/test_import_with_conflicting_action_statements.yml",
            2,
            4,
            id="0",
        ),
        pytest.param("examples/playbooks/test_import_with_malformed.yml", 2, 1, id="1"),
    ),
)
def test_import_tasks(
    default_rules_collection: RulesCollection,
    playbook_path: str,
    lintable_count: int,
    match_count: int,
) -> None:
    """Assures import_playbook includes are recognized."""
    runner = Runner(playbook_path, rules=default_rules_collection)
    results = runner.run()

    assert len(runner.lintables) == lintable_count
    assert len(results) == match_count
    # Assures we detected the issues from imported file
    assert results[0].rule.id in ("syntax-check", "load-failure")