summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-07-18 10:52:11 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-07-18 10:52:11 -0700
commitf9d18e2ed747a6d44e60547fbcc0bbff780f351f (patch)
tree66a2f42ac631081e848c7c849d1ceaf673a7f12d /tests
parent960f7c637d07c81f9e8dab2c81f113ee6654f31d (diff)
downloadvyos-cloud-init-f9d18e2ed747a6d44e60547fbcc0bbff780f351f.tar.gz
vyos-cloud-init-f9d18e2ed747a6d44e60547fbcc0bbff780f351f.zip
Add non braces matching and a few more tests
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_templating.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unittests/test_templating.py b/tests/unittests/test_templating.py
index c3faac3d..5601a2e1 100644
--- a/tests/unittests/test_templating.py
+++ b/tests/unittests/test_templating.py
@@ -68,3 +68,39 @@ $a,$b'''
blob = '''$a,$b'''
c = templater.render_string(blob, {"a": 1, "b": 2})
self.assertEquals("1,2", c)
+
+ def test_render_basic_deeper(self):
+ hn = 'myfoohost.yahoo.com'
+ expected_data = "h=%s\nc=d\n" % hn
+ in_data = "h=$hostname.canonical_name\nc=d\n"
+ params = {
+ "hostname": {
+ "canonical_name": hn,
+ },
+ }
+ out_data = templater.render_string(in_data, params)
+ self.assertEqual(expected_data, out_data)
+
+ def test_render_basic_no_parens(self):
+ hn = "myfoohost"
+ in_data = "h=$hostname\nc=d\n"
+ expected_data = "h=%s\nc=d\n" % hn
+ out_data = templater.basic_render(in_data, {'hostname': hn})
+ self.assertEqual(expected_data, out_data)
+
+ def test_render_basic_parens(self):
+ hn = "myfoohost"
+ in_data = "h = ${hostname}\nc=d\n"
+ expected_data = "h = %s\nc=d\n" % hn
+ out_data = templater.basic_render(in_data, {'hostname': hn})
+ self.assertEqual(expected_data, out_data)
+
+ def test_render_basic2(self):
+ mirror = "mymirror"
+ codename = "zany"
+ in_data = "deb $mirror $codename-updates main contrib non-free"
+ ex_data = "deb %s %s-updates main contrib non-free" % (mirror, codename)
+
+ out_data = templater.basic_render(in_data,
+ {'mirror': mirror, 'codename': codename})
+ self.assertEqual(ex_data, out_data)