mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-02 23:31:25 -07:00
Finishing touches on template cleanup.
This commit is contained in:
parent
1e85c7544b
commit
5031104c3a
3 changed files with 71 additions and 47 deletions
|
@ -9,6 +9,7 @@ from nose.plugins.skip import SkipTest
|
|||
|
||||
import ansible.utils
|
||||
import ansible.utils.template as template2
|
||||
import ansible.constants as C
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
|
||||
|
@ -16,6 +17,10 @@ class TestUtils(unittest.TestCase):
|
|||
### varReplace function tests
|
||||
|
||||
def test_varReplace_var_complex_var(self):
|
||||
|
||||
old_setting = C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = True
|
||||
|
||||
vars = {
|
||||
'x': '$y',
|
||||
'y': {
|
||||
|
@ -26,6 +31,8 @@ class TestUtils(unittest.TestCase):
|
|||
res = template2.template(None, template, vars)
|
||||
assert res == 'result'
|
||||
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = old_setting
|
||||
|
||||
#####################################
|
||||
### template_ds function tests
|
||||
|
||||
|
@ -53,6 +60,9 @@ class TestUtils(unittest.TestCase):
|
|||
],
|
||||
}
|
||||
|
||||
old_setting = C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = True
|
||||
|
||||
template = '${data.var}'
|
||||
res = template2.template(None, template, vars)
|
||||
assert sorted(res) == sorted(vars['data']['var'])
|
||||
|
@ -69,6 +79,8 @@ class TestUtils(unittest.TestCase):
|
|||
res = template2.template(None, template, vars)
|
||||
assert res == template
|
||||
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = old_setting
|
||||
|
||||
#####################################
|
||||
### Template function tests
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue