summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-07-16 11:31:31 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-07-16 11:31:31 -0700
commit7dfabbefbadf626503bed8fe4c6e79243bde73ce (patch)
tree40e008ed320d47d2dc4af7127ba0e39ccfa58d1a /tests
parentb740568ddfe6194af7c2c5d7123b3cc2a07fa7f7 (diff)
downloadvyos-cloud-init-7dfabbefbadf626503bed8fe4c6e79243bde73ce.tar.gz
vyos-cloud-init-7dfabbefbadf626503bed8fe4c6e79243bde73ce.zip
Add basic renderer support and more robust import handling
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_templating.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/unittests/test_templating.py b/tests/unittests/test_templating.py
index b4f425a8..c3faac3d 100644
--- a/tests/unittests/test_templating.py
+++ b/tests/unittests/test_templating.py
@@ -18,21 +18,35 @@
from tests.unittests import helpers as test_helpers
-
from cloudinit import templater
class TestTemplates(test_helpers.TestCase):
+ def test_render_basic(self):
+ in_data = """
+${b}
+
+c = d
+"""
+ in_data = in_data.strip()
+ expected_data = """
+2
+
+c = d
+"""
+ out_data = templater.basic_render(in_data, {'b': 2})
+ self.assertEqual(expected_data.strip(), out_data)
+
def test_detection(self):
blob = "## template:cheetah"
- (template_type, contents) = templater.detect_template(blob)
- self.assertEqual("cheetah", template_type)
+ (template_type, renderer, contents) = templater.detect_template(blob)
+ self.assertIn("cheetah", template_type)
self.assertEqual("", contents.strip())
blob = "blahblah $blah"
- (template_type, contents) = templater.detect_template(blob)
- self.assertEqual("cheetah", template_type)
+ (template_type, renderer, contents) = templater.detect_template(blob)
+ self.assertIn("cheetah", template_type)
self.assertEquals(blob, contents)
blob = '##template:something-new'