예제 #1
0
파일: test_layout.py 프로젝트: sidloki/ptah
    def test_layout_chain_parent_notfound(self):
        self.config.add_layout('',
                               context=Context,
                               parent='page',
                               renderer='ptah.renderer:tests/test-layout.pt')

        root = Root()
        context = Context(root)

        from ptah.renderer.layout_impl import LayoutRenderer
        renderer = LayoutRenderer('')

        res = renderer('View: test', context, self.request)
        self.assertTrue('<div>View: test</div>' in text_(res))
예제 #2
0
파일: test_layout.py 프로젝트: sidloki/ptah
    def test_layout_simple_declarative(self):
        from ptah.renderer.layout_impl import LayoutRenderer

        class Layout(View):
            def __call__(self):
                return None

        self.config.add_layout(
            'test',
            context=Context,
            renderer='ptah.renderer:tests/test-layout-html.pt')

        renderer = LayoutRenderer('test')
        res = renderer('View: test', Context(), self.request)
        self.assertEqual(res.strip(), '<html>View: test</html>')
예제 #3
0
파일: test_layout.py 프로젝트: sidloki/ptah
    def test_layout_simple_chain_multi_level(self):
        from ptah.renderer.layout_impl import LayoutRenderer

        self.config.add_layout('test',
                               parent='.',
                               renderer='ptah.renderer:tests/test-layout.pt')
        self.config.add_layout(
            '',
            context=Root,
            parent=None,
            renderer='ptah.renderer:tests/test-layout-html.pt')

        root = Root()
        context = Context(root)
        renderer = LayoutRenderer('test')

        res = renderer('View: test', context, self.request)
        self.assertIn('<html><div>View: test</div>\n</html>', text_(res))
예제 #4
0
파일: test_layout.py 프로젝트: sidloki/ptah
    def test_layout_chain_same_layer_id_on_different_levels(self):
        from ptah.renderer.layout_impl import LayoutRenderer

        self.config.add_layout('',
                               context=Context,
                               parent='.',
                               renderer='ptah.renderer:tests/test-layout.pt')
        self.config.add_layout(
            '',
            context=Root,
            parent=None,
            renderer='ptah.renderer:tests/test-layout-html.pt')

        root = Root()
        context1 = Context2(root)
        context2 = Context(context1)
        renderer = LayoutRenderer('')

        res = renderer('View: test', context2, self.request)
        self.assertIn('<html><div>View: test</div>\n</html>', text_(res))