-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related: #4122
- Loading branch information
Showing
7 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Sample action_plugin.""" | ||
|
||
from ansible.plugins.action import ActionBase | ||
|
||
|
||
class ActionModule(ActionBase): # type: ignore[misc] | ||
"""Sample module.""" | ||
|
||
def run(self, tmp=None, task_vars=None): # type: ignore[no-untyped-def] | ||
""".""" | ||
super().run(tmp, task_vars) | ||
ret = {"foo": "bar"} | ||
return {"ansible_facts": ret} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: Fixture for testing adjacent plugins | ||
hosts: localhost | ||
tasks: | ||
- name: Call adjacent action plugin | ||
some_action: {} | ||
|
||
- name: Call adjacent filter plugin | ||
ansible.builtin.debug: | ||
msg: "{{ 'foo' | some_filter }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Sample adjacent filter plugin.""" | ||
|
||
from __future__ import annotations | ||
|
||
|
||
class FilterModule: # pylint: disable=too-few-public-methods | ||
"""Ansible filters.""" | ||
|
||
def filters(self): # type: ignore[no-untyped-def] | ||
"""Return list of exposed filters.""" | ||
return { | ||
"some_filter": str, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Test ability to recognize adjacent modules/plugins.""" | ||
|
||
import logging | ||
|
||
import pytest | ||
|
||
from ansiblelint.rules import RulesCollection | ||
from ansiblelint.runner import Runner | ||
|
||
|
||
def test_adj_action( | ||
default_rules_collection: RulesCollection, | ||
caplog: pytest.LogCaptureFixture, | ||
) -> None: | ||
"""Assures local collections are found.""" | ||
playbook_path = "examples/playbooks/adj_action.yml" | ||
|
||
with caplog.at_level(logging.DEBUG): | ||
runner = Runner(playbook_path, rules=default_rules_collection, verbosity=1) | ||
results = runner.run() | ||
assert "Unable to load module" not in caplog.text | ||
assert "Unable to resolve FQCN" not in caplog.text | ||
|
||
assert len(runner.lintables) == 1 | ||
assert len(results) == 0 |