-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add has_jinja and has_glob to text module (#2794)
This should make it easier to reuse these utility functions. Related: #2749
- Loading branch information
Showing
5 changed files
with
62 additions
and
8 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
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,39 @@ | ||
"""Tests for text module.""" | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from ansiblelint.text import has_glob, has_jinja | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("value", "expected"), | ||
( | ||
pytest.param("", False, id="0"), | ||
pytest.param("{{ }}", True, id="1"), | ||
pytest.param("foo {# #} bar", True, id="2"), | ||
pytest.param("foo \n{% %} bar", True, id="3"), | ||
pytest.param(None, False, id="4"), | ||
pytest.param(42, False, id="5"), | ||
pytest.param(True, False, id="6"), | ||
), | ||
) | ||
def test_has_jinja(value: Any, expected: bool) -> None: | ||
"""Tests for has_jinja().""" | ||
assert has_jinja(value) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("value", "expected"), | ||
( | ||
pytest.param("", False, id="0"), | ||
pytest.param("*", True, id="1"), | ||
pytest.param("foo.*", True, id="2"), | ||
pytest.param(None, False, id="4"), | ||
pytest.param(42, False, id="5"), | ||
pytest.param(True, False, id="6"), | ||
), | ||
) | ||
def test_has_glob(value: Any, expected: bool) -> None: | ||
"""Tests for has_jinja().""" | ||
assert has_glob(value) == expected |