summaryrefslogtreecommitdiffstats
path: root/test/test_skip_import_playbook.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
commit2fe34b6444502079dc0b84365ce82dbc92de308e (patch)
tree8fedcab52bbbc3db6c5aa909a88a7a7b81685018 /test/test_skip_import_playbook.py
parentInitial commit. (diff)
downloadansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.tar.xz
ansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.zip
Adding upstream version 6.17.2.upstream/6.17.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test_skip_import_playbook.py')
-rw-r--r--test/test_skip_import_playbook.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/test_skip_import_playbook.py b/test/test_skip_import_playbook.py
new file mode 100644
index 0000000..777fec6
--- /dev/null
+++ b/test/test_skip_import_playbook.py
@@ -0,0 +1,49 @@
+"""Test related to skipping import_playbook."""
+from pathlib import Path
+
+import pytest
+
+from ansiblelint.rules import RulesCollection
+from ansiblelint.runner import Runner
+
+IMPORTED_PLAYBOOK = """\
+---
+- name: Fixture
+ hosts: all
+ tasks:
+ - name: Success # noqa: no-free-form
+ ansible.builtin.fail: msg="fail"
+ when: false
+"""
+
+MAIN_PLAYBOOK = """\
+---
+- name: Fixture
+ hosts: all
+
+ tasks:
+ - name: Should be shell # noqa: command-instead-of-shell no-changed-when no-free-form
+ ansible.builtin.shell: echo lol
+
+- name: Should not be imported
+ import_playbook: imported_playbook.yml
+"""
+
+
+@pytest.fixture(name="playbook")
+def fixture_playbook(tmp_path: Path) -> str:
+ """Create a reusable per-test playbook."""
+ playbook_path = tmp_path / "playbook.yml"
+ playbook_path.write_text(MAIN_PLAYBOOK)
+ (tmp_path / "imported_playbook.yml").write_text(IMPORTED_PLAYBOOK)
+ return str(playbook_path)
+
+
+def test_skip_import_playbook(
+ default_rules_collection: RulesCollection,
+ playbook: str,
+) -> None:
+ """Verify that a playbook import is skipped after a failure."""
+ runner = Runner(playbook, rules=default_rules_collection)
+ results = runner.run()
+ assert len(results) == 0