Exemplo n.º 1
0
    def test_non_callable_attributes(self):
        view = Simple()
        view.thing = 'Chris'

        renderer = Renderer()
        actual = renderer.render(view)
        self.assertEqual(actual, "Hi Chris!")
Exemplo n.º 2
0
    def test_non_callable_attributes(self):
        view = Simple()
        view.thing = 'Chris'

        renderer = Renderer()
        actual = renderer.render(view)
        self.assertEqual(actual, "Hi Chris!")
Exemplo n.º 3
0
    def test_accessing_properties_on_parent_object_from_child_objects(self):
        parent = Thing()
        parent.this = 'derp'
        parent.children = [Thing()]
        view = Simple(context={'parent': parent})
        view.template = "{{#parent}}{{#children}}{{this}}{{/children}}{{/parent}}"

        self.assertEquals(view.render(), 'derp')
Exemplo n.º 4
0
 def test_template_load_from_multiple_path(self):
     path = Simple.template_path
     Simple.template_path = ('examples/nowhere','examples',)
     try:
         view = Simple(thing='world')
         self.assertEquals(view.render(), "Hi world!")
     finally:
         Simple.template_path = path
Exemplo n.º 5
0
 def test_accessing_properties_on_parent_object_from_child_objects(self):
     parent = Thing()
     parent.this = 'derp'
     parent.children = [Thing()]
     view = Simple(context={'parent': parent})
     view.template = "{{#parent}}{{#children}}{{this}}{{/children}}{{/parent}}"
     
     self.assertEquals(view.render(), 'derp')
Exemplo n.º 6
0
 def test_template_load_from_multiple_path(self):
     path = Simple.template_path
     Simple.template_path = ('examples/nowhere','examples',)
     try:
         view = Simple(thing='world')
         self.assertEquals(view.render(), "Hi world!")
     finally:
         Simple.template_path = path
Exemplo n.º 7
0
    def test_render__partials(self):
        """
        Test passing partials to View.__init__().

        """
        template = "{{>partial}}"
        partials = {"partial": "Loaded from dictionary"}
        view = Simple(template=template, partials=partials)
        actual = view.render()

        self.assertEquals(actual, "Loaded from dictionary")
Exemplo n.º 8
0
    def test_render__partials(self):
        """
        Test passing partials to View.__init__().

        """
        template = "{{>partial}}"
        partials = {"partial": "Loaded from dictionary"}
        view = Simple(template=template, partials=partials)
        actual = view.render()

        self.assertEquals(actual, "Loaded from dictionary")
Exemplo n.º 9
0
    def test_accessing_properties_on_parent_object_from_child_objects(self):
        parent = Thing()
        parent.this = 'derp'
        parent.children = [Thing()]
        view = Simple()
        view.template = "{{#parent}}{{#children}}{{this}}{{/children}}{{/parent}}"

        renderer = Renderer()
        actual = renderer.render(view, {'parent': parent})

        self.assertString(actual, u'derp')
Exemplo n.º 10
0
    def test_accessing_properties_on_parent_object_from_child_objects(self):
        parent = Thing()
        parent.this = 'derp'
        parent.children = [Thing()]
        view = Simple()
        view.template = "{{#parent}}{{#children}}{{this}}{{/children}}{{/parent}}"

        renderer = Renderer()
        actual = renderer.render(view, {'parent': parent})

        self.assertString(actual, u'derp')
Exemplo n.º 11
0
 def test_template_load_from_multiple_path_fail(self):
     path = Simple.template_path
     Simple.template_path = ('examples/nowhere', )
     try:
         view = Simple(thing='world')
         self.assertRaises(IOError, view.render)
     finally:
         Simple.template_path = path
Exemplo n.º 12
0
    def test_render__view(self):
        """
        Test rendering a View instance.

        """
        renderer = Renderer()

        view = Simple()
        actual = renderer.render(view)
        self.assertEqual('Hi pizza!', actual)
Exemplo n.º 13
0
 def test_view_instances_as_attributes(self):
     other = Simple(name='chris')
     other.template = '{{name}}'
     view = Simple()
     view.thing = other
     self.assertEquals(view.render(), "Hi chris!")
Exemplo n.º 14
0
 def test_non_callable_attributes(self):
     view = Simple()
     view.thing = 'Chris'
     self.assertEquals(view.render(), "Hi Chris!")
Exemplo n.º 15
0
 def test_basic_method_calls(self):
     view = Simple()
     self.assertEquals(view.render(), "Hi pizza!")
Exemplo n.º 16
0
 def test_template_load(self):
     view = Simple(thing='world')
     self.assertEquals(view.render(), "Hi world!")
Exemplo n.º 17
0
 def test_kwargs(self):
     view = Simple("Hi {{thing}}!", thing='world')
     self.assertEquals(view.render(), "Hi world!")
Exemplo n.º 18
0
    def test_non_existent_value_renders_blank(self):
        view = Simple()

        self.assertEquals(
            pystache.Template('{{not_set}} {{blank}}', view).render(), ' ')
Exemplo n.º 19
0
 def test_kwargs(self):
     view = Simple("Hi {{thing}}!", thing='world')
     self.assertEquals(view.render(), "Hi world!")
Exemplo n.º 20
0
 def test_basic_sections(self):
     view = Simple("{{#x}}{{#x}}x{{/x}}{{/x}}", { 'x': [{'x':[1,2,3]},{'x':[4,5,6]}] })
     self.assertEquals(view.render(), "xxxxxx")
Exemplo n.º 21
0
    def test_context_returns_a_flattened_dict(self):
        view = Simple()
        view.context_list = [{'one':'1'}, {'two':'2'}, object()]

        self.assertEqual(view.context, {'one': '1', 'two': '2'})
Exemplo n.º 22
0
 def test_non_existent_value_renders_blank(self):
     view = Simple()
     template = '{{not_set}} {{blank}}'
     self.assertEqual(pystache.Renderer().render(template), ' ')
Exemplo n.º 23
0
    def test_basic_method_calls(self):
        renderer = Renderer()
        actual = renderer.render(Simple())

        self.assertString(actual, u"Hi pizza!")
Exemplo n.º 24
0
 def test_basic_method_calls(self):
     view = Simple()
     self.assertEquals(view.render(), "Hi pizza!")
Exemplo n.º 25
0
 def test_template_load(self):
     view = Simple(thing='world')
     self.assertEquals(view.render(), "Hi world!")
Exemplo n.º 26
0
 def test_basic(self):
     view = Simple("Hi {{thing}}!", { 'thing': 'world' })
     self.assertEquals(view.render(), "Hi world!")
Exemplo n.º 27
0
 def test_basic(self):
     view = Simple("Hi {{thing}}!", {"thing": "world"})
     self.assertEquals(view.render(), "Hi world!")
Exemplo n.º 28
0
 def test_basic(self):
     view = Simple("Hi {{thing}}!", {'thing': 'world'})
     self.assertEquals(view.render(), "Hi world!")
Exemplo n.º 29
0
 def test_non_callable_attributes(self):
     view = Simple()
     view.thing = 'Chris'
     self.assertEquals(view.render(), "Hi Chris!")
Exemplo n.º 30
0
    def test_context_returns_a_flattened_dict(self):
        view = Simple()
        view.context_list = [{'one':'1'}, {'two':'2'}, object()]

        self.assertEqual(view.context, {'one': '1', 'two': '2'})
Exemplo n.º 31
0
 def test_view_instances_as_attributes(self):
     other = Simple(name='chris')
     other.template = '{{name}}'
     view = Simple()
     view.thing = other
     self.assertEquals(view.render(), "Hi chris!")
Exemplo n.º 32
0
    def test_context_returns_a_flattened_dict(self):
        view = Simple()
        view.context_list = [{"one": "1"}, {"two": "2"}, object()]

        self.assertEqual(view.context, {"one": "1", "two": "2"})