mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-02 23:31:25 -07:00
Add regex (search, match, regex) jinja2 filters. Fixes #3725
This commit is contained in:
parent
119b6d73dd
commit
61525a97df
2 changed files with 54 additions and 0 deletions
|
@ -89,6 +89,33 @@ class TestFilters(unittest.TestCase):
|
|||
a = ansible.runner.filter_plugins.core.fileglob(pathname)
|
||||
assert __file__ in a
|
||||
|
||||
def test_regex(self):
|
||||
a = ansible.runner.filter_plugins.core.regex('ansible', 'ansible',
|
||||
match_type='findall')
|
||||
assert a == True
|
||||
|
||||
def test_match_case_sensitive(self):
|
||||
a = ansible.runner.filter_plugins.core.match('ansible', 'ansible')
|
||||
assert a == True
|
||||
|
||||
def test_match_case_insensitive(self):
|
||||
a = ansible.runner.filter_plugins.core.match('ANSIBLE', 'ansible',
|
||||
True)
|
||||
assert a == True
|
||||
|
||||
def test_match_no_match(self):
|
||||
a = ansible.runner.filter_plugins.core.match(' ansible', 'ansible')
|
||||
assert a == False
|
||||
|
||||
def test_search_case_sensitive(self):
|
||||
a = ansible.runner.filter_plugins.core.search(' ansible ', 'ansible')
|
||||
assert a == True
|
||||
|
||||
def test_search_case_insensitive(self):
|
||||
a = ansible.runner.filter_plugins.core.search(' ANSIBLE ', 'ansible',
|
||||
True)
|
||||
assert a == True
|
||||
|
||||
#def test_filters(self):
|
||||
|
||||
# this test is pretty low level using a playbook, hence I am disabling it for now -- MPD.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue