summaryrefslogtreecommitdiffstats
path: root/test/test_task_includes.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_task_includes.py')
-rw-r--r--test/test_task_includes.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/test_task_includes.py b/test/test_task_includes.py
new file mode 100644
index 0000000..3b02d00
--- /dev/null
+++ b/test/test_task_includes.py
@@ -0,0 +1,47 @@
+"""Tests related to task inclusions."""
+import pytest
+
+from ansiblelint.file_utils import Lintable
+from ansiblelint.rules import RulesCollection
+from ansiblelint.runner import Runner
+
+
+@pytest.mark.parametrize(
+ ("filename", "file_count", "match_count"),
+ (
+ pytest.param("examples/playbooks/blockincludes.yml", 4, 3, id="blockincludes"),
+ pytest.param(
+ "examples/playbooks/blockincludes2.yml",
+ 4,
+ 3,
+ id="blockincludes2",
+ ),
+ pytest.param("examples/playbooks/taskincludes.yml", 3, 6, id="taskincludes"),
+ pytest.param("examples/playbooks/taskimports.yml", 5, 3, id="taskimports"),
+ pytest.param(
+ "examples/playbooks/include-in-block.yml",
+ 3,
+ 1,
+ id="include-in-block",
+ ),
+ pytest.param(
+ "examples/playbooks/include-import-tasks-in-role.yml",
+ 4,
+ 2,
+ id="role_with_task_inclusions",
+ ),
+ ),
+)
+def test_included_tasks(
+ default_rules_collection: RulesCollection,
+ filename: str,
+ file_count: int,
+ match_count: int,
+) -> None:
+ """Check if number of loaded files is correct."""
+ lintable = Lintable(filename)
+ default_rules_collection.options.enable_list = ["name[prefix]"]
+ runner = Runner(lintable, rules=default_rules_collection)
+ result = runner.run()
+ assert len(runner.lintables) == file_count
+ assert len(result) == match_count