Skip to content

Commit

Permalink
Add test_is_nested_task()
Browse files Browse the repository at this point in the history
  • Loading branch information
nishipy committed Apr 29, 2022
1 parent eb2343a commit c40c7bc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:TOX_PARALLEL_NO_SPINNER
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests.
PYTEST_REQPASS: 608
PYTEST_REQPASS: 610

steps:
- name: Activate WSL1
Expand Down
38 changes: 38 additions & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,41 @@ def test_nested_items() -> None:
match=r"Call to deprecated function ansiblelint\.utils\.nested_items.*"
):
assert list(utils.nested_items(data)) == items


@pytest.mark.parametrize(
("task", "expected"),
(
pytest.param(
dict(
name="ensure apache is at the latest version",
yum={"name": "httpd", "state": "latest"},
),
False,
),
pytest.param(
dict(
name="Attempt and graceful roll back",
block=[
{"name": "Force a failure", "ansible.builtin.command": "/bin/false"}
],
rescue=[
{
"name": "Force a failure in middle of recovery!",
"ansible.builtin.command": "/bin/false",
}
],
always=[
{
"name": "Always do this",
"ansible.builtin.debug": {"msg": "This always executes"},
}
],
),
True,
),
),
)
def test_is_nested_task(task: Dict[str, Any], expected: bool) -> None:
"""Test is_nested_task() returns expected bool."""
assert utils.is_nested_task(task) == expected

0 comments on commit c40c7bc

Please sign in to comment.