def testNone(self): """Test that a dict with None as a value resolves correctly.""" self.assertEqual( render_targs({"a": None}), {"a": None} )
def testList(self): """Verify that lists can be used as values and manipulated by the template.""" self.assertEqual( render_targs({"a": "{{b|join(' ')}}", "b": ["foo", "bar"]}), {"a": "foo bar", "b": ["foo", "bar"]} )
def testResolves(self): """Verify that a dict with legal values resolves correctly.""" self.assertEqual( render_targs({"a": "{{ b }}", "b": "{{c}}", "c": "d"}), {"a": "d", "b": "d", "c": "d"} )
def testSelfReference(self): """Test for failure when a targ refers to itself.""" with self.assertRaises(UnresolvableTemplate) as r: render_targs({"a": "{{a}}"}) self.assertIn("a={{a}}", str(r.exception))
def testMissingValue(self): """Test for failure when a template value is not provided.""" with self.assertRaises(UnresolvableTemplate) as r: render_targs({"a": "{{b}}"}) self.assertIn("Missing template value:", str(r.exception))
def testCirularReference_twoVarsWithText(self): with self.assertRaises(UnresolvableTemplate) as r: render_targs({"a": "the {{b}}", "b": "only {{a}}"}) self.assertIn("a=the {{b}}, b=only {{a}}", str(r.exception))
def testCircularReference_varWithText(self): """Test for failure when there is a circular reference in targs.""" with self.assertRaises(UnresolvableTemplate) as r: render_targs({"a": "{{b}}", "b": "foo {{c}}", "c": "{{a}}"}) self.assertIn("a={{b}}, b=foo {{c}}, c={{a}}", str(r.exception))
def testMutualReference(self): """Test for failure when targs refer directly to each other.""" with self.assertRaises(UnresolvableTemplate) as r: render_targs({"a": "{{b}}", "b": "{{a}}"}) self.assertIn("a={{b}}, b={{a}}", str(r.exception))
def testVarWithSpace(self): """Verify spaces are not allowed inside of jinja template variables. (and we don't expect it).""" with self.assertRaises(jinja2.exceptions.TemplateSyntaxError): render_targs({"abc def": "foo", "ghi jkl": "{{abc def}}"})
def testBool(self): """Test that a dict with a bool as a value resolves correctly.""" self.assertEqual( render_targs({"a": True}), {"a": True} )