From 031c75e53aa4065b947b9a2dc7559e0e4ae3fd15 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 18 Jun 2012 00:12:42 +0200 Subject: [PATCH] Update tests to reflect new API --- test/TestUtils.py | 63 +++++++++++++++++++--------------------- test/template-basic | 1 + test/template-whitespace | 1 + 3 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 test/template-basic create mode 100644 test/template-whitespace diff --git a/test/TestUtils.py b/test/TestUtils.py index b83dcb0312d..84601c6f050 100644 --- a/test/TestUtils.py +++ b/test/TestUtils.py @@ -203,39 +203,6 @@ class TestUtils(unittest.TestCase): assert res == 'hello world' - ##################################### - ### Template function tests - - def test_template_basic(self): - template = 'hello {{ who }}' - vars = { - 'who': 'world', - } - - res = ansible.utils.template(template, vars, {}, no_engine=False) - - assert res == 'hello world' - - def test_template_whitespace(self): - template = 'hello {{ who }}\n' - vars = { - 'who': 'world', - } - - res = ansible.utils.template(template, vars, {}, no_engine=False) - - assert res == 'hello world\n' - - def test_template_unicode(self): - template = 'hello {{ who }}' - vars = { - 'who': u'wórld', - } - - res = ansible.utils.template(template, vars, {}, no_engine=False) - - assert res == u'hello wórld' - def test_template_varReplace_iterated(self): template = 'hello $who' vars = { @@ -247,6 +214,36 @@ class TestUtils(unittest.TestCase): assert res == u'hello oh great one' + ##################################### + ### Template function tests + + def test_template_basic(self): + vars = { + 'who': 'world', + } + + res = ansible.utils.template_from_file("test", "template-basic", vars, {}) + + assert res == 'hello world' + + def test_template_whitespace(self): + vars = { + 'who': 'world', + } + + res = ansible.utils.template_from_file("test", "template-whitespace", vars, {}) + + assert res == 'hello world\n' + + def test_template_unicode(self): + vars = { + 'who': u'wórld', + } + + res = ansible.utils.template_from_file("test", "template-basic", vars, {}) + + assert res == u'hello wórld' + ##################################### ### key-value parsing diff --git a/test/template-basic b/test/template-basic new file mode 100644 index 00000000000..9aa58b909c2 --- /dev/null +++ b/test/template-basic @@ -0,0 +1 @@ +hello {{ who }} \ No newline at end of file diff --git a/test/template-whitespace b/test/template-whitespace new file mode 100644 index 00000000000..795953837b8 --- /dev/null +++ b/test/template-whitespace @@ -0,0 +1 @@ +hello {{ who }}