diff options
author | Michael DeHaan <michael@ansibleworks.com> | 2013-04-11 01:09:57 +0200 |
---|---|---|
committer | Michael DeHaan <michael@ansibleworks.com> | 2013-04-11 01:09:57 +0200 |
commit | 81a926547cc7232277280addf4062561dfc49ece (patch) | |
tree | 9fd7e39e7042b13bd866bffa62505beb48eb3bcb /test | |
parent | allow references to names of variables in with_items without needing to surro... (diff) | |
download | ansible-81a926547cc7232277280addf4062561dfc49ece.tar.xz ansible-81a926547cc7232277280addf4062561dfc49ece.zip |
Some continued work on new-style templates and associated test code changes. Legacy template functions
are marked with "legacy_" for possible future removal.
Diffstat (limited to 'test')
-rw-r--r-- | test/TestUtils.py | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/test/TestUtils.py b/test/TestUtils.py index c1d5870cdd..1a3d488985 100644 --- a/test/TestUtils.py +++ b/test/TestUtils.py @@ -3,7 +3,7 @@ import unittest import ansible.utils -import ansible.template as template +import ansible.utils.template as template2 class TestUtils(unittest.TestCase): @@ -16,14 +16,14 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world' def test_varReplace_trailing_dollar(self): template = '$what $who $' vars = dict(what='hello', who='world') - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world $' def test_varReplace_multiple(self): @@ -33,7 +33,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world' @@ -43,7 +43,7 @@ class TestUtils(unittest.TestCase): 'whoVar': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) print res assert res == 'hello world' @@ -53,7 +53,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world!' @@ -63,7 +63,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world' @@ -73,7 +73,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world}' @@ -83,7 +83,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == template @@ -93,7 +93,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world }' @@ -105,7 +105,7 @@ class TestUtils(unittest.TestCase): }, } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) print res assert res == template @@ -118,7 +118,7 @@ class TestUtils(unittest.TestCase): }, } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world' @@ -131,7 +131,7 @@ class TestUtils(unittest.TestCase): 'what': 'hello', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello 2' @@ -141,7 +141,7 @@ class TestUtils(unittest.TestCase): 'who': u'wórld', } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == u'hello wórld' @@ -151,7 +151,7 @@ class TestUtils(unittest.TestCase): 'data': [ 'no-one', 'world' ] } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world' @@ -161,7 +161,7 @@ class TestUtils(unittest.TestCase): 'data': [ 'no-one', 'world' ] } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == template @@ -171,7 +171,7 @@ class TestUtils(unittest.TestCase): 'data': [ 'no-one', 'world' ] } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == template @@ -181,7 +181,7 @@ class TestUtils(unittest.TestCase): 'data': { 'no-one': 0, 'world': 1 } } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == template @@ -191,7 +191,7 @@ class TestUtils(unittest.TestCase): 'data': [ 'no-one', {'msg': [ 'world'] } ] } - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'hello world' @@ -202,7 +202,7 @@ class TestUtils(unittest.TestCase): } template = '${foo}${bar}' - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'foobar' def test_varReplace_escape_dot(self): @@ -215,7 +215,7 @@ class TestUtils(unittest.TestCase): } template = '${hostvars.{test.example.com}.foo}' - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'bar' def test_varReplace_list_join(self): @@ -228,7 +228,7 @@ class TestUtils(unittest.TestCase): } template = 'yum pkg=${list} state=installed' - res = ansible.utils.varReplace(None, template, vars, expand_lists=True) + res = template2.legacy_varReplace(None, template, vars, expand_lists=True) assert res == 'yum pkg=foo,bar,baz state=installed' def test_varReplace_escaped_var(self): @@ -236,7 +236,7 @@ class TestUtils(unittest.TestCase): 'foo': 'bar', } template = 'action \$foo' - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'action $foo' def test_varReplace_var_part(self): @@ -247,7 +247,7 @@ class TestUtils(unittest.TestCase): 'key': 'bar', } template = 'test ${foo.$key}' - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'test result' def test_varReplace_var_partial_part(self): @@ -258,7 +258,7 @@ class TestUtils(unittest.TestCase): 'key': 'bar', } template = 'test ${foo.${key}baz}' - res = ansible.utils.varReplace(None, template, vars) + res = template2.legacy_varReplace(None, template, vars) assert res == 'test result' def test_varReplace_var_complex_var(self): @@ -269,7 +269,7 @@ class TestUtils(unittest.TestCase): }, } template = '${x.foo}' - res = template.template(None, template, vars) + res = template2.template(None, template, vars) assert res == 'result' def test_template_varReplace_iterated(self): @@ -279,21 +279,21 @@ class TestUtils(unittest.TestCase): 'person': 'one', } - res = template.template(None, template, vars) + res = template2.template(None, template, vars) assert res == u'hello oh great one' def test_varReplace_include(self): template = 'hello $FILE(world) $LOOKUP(file, $filename)' - res = template.template("test", template, {'filename': 'world'}, expand_lists=True) + res = template2.template("test", template, {'filename': 'world'}, expand_lists=True) assert res == u'hello world world' def test_varReplace_include_script(self): template = 'hello $PIPE(echo world) $LOOKUP(pipe, echo world)' - res = template.template("test", template, {}, expand_lists=True) + res = template2.template("test", template, {}, expand_lists=True) assert res == u'hello world world' @@ -325,19 +325,19 @@ class TestUtils(unittest.TestCase): } template = '${data.var}' - res = template.template(None, template, vars) + res = template2.template(None, template, vars) assert sorted(res) == sorted(vars['data']['var']) template = '${data.types}' - res = template.template(None, template, vars) + res = template2.template(None, template, vars) assert sorted(res) == sorted(vars['data']['types']) template = '${data.alphas}' - res = template.template(None, template, vars) + res = template2.template(None, template, vars) assert sorted(res) == sorted(vars['alphas']) template = '${data.nonexisting}' - res = template.template(None, template, vars) + res = template2.template(None, template, vars) assert res == template ##################################### @@ -348,7 +348,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = template.template_from_file("test", "template-basic", vars) + res = template2.template_from_file("test", "template-basic", vars) assert res == 'hello world' @@ -357,7 +357,7 @@ class TestUtils(unittest.TestCase): 'who': 'world', } - res = template.template_from_file("test", "template-whitespace", vars) + res = template2.template_from_file("test", "template-whitespace", vars) assert res == 'hello world\n' @@ -366,7 +366,7 @@ class TestUtils(unittest.TestCase): 'who': u'wórld', } - res = template.template_from_file("test", "template-basic", vars) + res = template2.template_from_file("test", "template-basic", vars) assert res == u'hello wórld' |