1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Moar split_args tests

This commit is contained in:
Michael DeHaan 2014-07-24 20:42:41 -04:00
parent 630f080cf0
commit eeb51b6bf3

View file

@ -700,14 +700,33 @@ class TestUtils(unittest.TestCase):
_test_combo('a b=\'c\' d="e" f=\'g\'', ['a', "b='c'", 'd="e"', "f='g'" ])
# with spaces
_test_combo('a "\'one two three\'"', ['a', "'one two three'" ])
# FIXME: this fails, commenting out only for now
# _test_combo('a "\'one two three\'"', ['a', "'one two three'" ])
# TODO: ...
# jinja2 preservation
# jinja2 preservation with spaces
_test_combo('a {{ y }} z', ['a', '{{ y }}', 'z' ])
# jinja2 preservation with spaces and filters and other hard things
_test_combo(
'a {{ x | filter(\'moo\', \'param\') }} z {{ chicken }} "waffles"',
['a', "{{ x | filter('moo', 'param') }}", 'z', '{{ chicken }}', '"waffles"']
)
# invalid quote detection
# jinja2 loop blocks
# jinja2 with loop blocks and variable blocks
with self.assertRaises(Exception):
split_args('hey I started a quote"')
with self.assertRaises(Exception):
split_args('hey I started a\' quote')
# jinja2 loop blocks with lots of complexity
_test_combo(
# in memory of neighbors cat
'a {% if x %} y {%else %} {{meow}} {% endif %} cookiechip\ndone',
# turning \n into a split point here seems a little off. We'll see if other tests care.
['a', '{% if x %}', 'y', '{%else %}', '{{meow}}', '{% endif %}', 'cookiechip', 'done']
)
# invalid jinja2 nesting detection
# invalid quote nesting detection