From 7dfabbefbadf626503bed8fe4c6e79243bde73ce Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 16 Jul 2014 11:31:31 -0700 Subject: Add basic renderer support and more robust import handling --- tests/unittests/test_templating.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'tests/unittests/test_templating.py') 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' -- cgit v1.2.3