def render(self, override_dict=None, **kwargs): dictcopy = copy.deepcopy(self) if override_dict is not None: dictcopy.update(override_dict) if len(kwargs.keys()) != 0: dictcopy.update(kwargs) return utils.render(self, dictcopy)
def test_render_list(self): """ Test that utils.render will correctly render a list of string templates and ignore strings without template variables. """ ts = [ "{{value1}}", "{{value2}}", "foobar", ] s = utils.render(ts, {"value1": "hello", "value2": "meow"}) self.assertEquals(["hello", "meow", "foobar"], s)
def test_render_dictionary(self): """ Test that utils.render will correctly render the values in a dictionary. """ ds = { "key1": "{{value1}}", "key2": "{{value2}}", "key3": "foobar", } s = utils.render(ds, {"value1": "hello", "value2": "meow"}) self.assertEquals({ "key1": "hello", "key2": "meow", "key3": "foobar"}, s)
def test_render_list_of_dictionaries(self): """ Test that utils.render will correctly render a list of dictionaries. """ ds = { "key1": "{{value1}}", "key2": "{{value2}}", "key3": "foobar", } ts = [ds, dict(ds)] s = utils.render(ts, {"value1": "hello", "value2": "meow"}) self.assertEquals([{ "key1": "hello", "key2": "meow", "key3": "foobar"}, { "key1": "hello", "key2": "meow", "key3": "foobar"}], s)
def test_render_string(self): """ Test that utils.render will correctly render a string template. """ s = utils.render("{{value}}", {"value": "hello"}) self.assertEquals("hello", s)