Add regex (search, match, regex) jinja2 filters. Fixes #3725

This commit is contained in:
Matt Martz 2013-10-11 08:03:04 -05:00
parent 119b6d73dd
commit 61525a97df
2 changed files with 54 additions and 0 deletions

View file

@ -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.