예제 #1
0
    def test_layout_chain_multi_level(self):
        class Layout1(View):
            """ """

        class Layout2(View):
            """ """

        class Layout3(View):
            """ """

        class Context1(object):
            """ """

        class Context2(object):
            """ """

        class Context3(object):
            """ """

        self.config.add_layout('l1', view=Layout1, context=Context1)
        self.config.add_layout('l1',
                               view=Layout2,
                               context=Context2,
                               parent='l1')
        self.config.add_layout('l3',
                               view=Layout3,
                               context=Context3,
                               parent='l1')

        root = Root()
        context1 = Context1()
        context2 = Context2()
        context3 = Context3()

        context1.__parent__ = root
        context2.__parent__ = context1
        context3.__parent__ = context2

        from player.layout_impl import query_layout_chain
        chain = query_layout_chain(root, context1, self.request, 'l1')

        self.assertEqual(len(chain), 1)
        self.assertIs(chain[0][0].original, Layout1)

        chain = query_layout_chain(root, context2, self.request, 'l1')

        self.assertEqual(len(chain), 2)
        self.assertIs(chain[0][0].original, Layout2)
        self.assertIs(chain[1][0].original, Layout1)

        chain = query_layout_chain(root, context3, self.request, 'l3')

        self.assertEqual(len(chain), 3)
        self.assertIs(chain[0][0].original, Layout3)
        self.assertIs(chain[1][0].original, Layout2)
        self.assertIs(chain[2][0].original, Layout1)
예제 #2
0
    def test_layout_chain_multi_level(self):
        class Layout1(View):
            """ """
        class Layout2(View):
            """ """
        class Layout3(View):
            """ """

        class Context1(object):
            """ """
        class Context2(object):
            """ """
        class Context3(object):
            """ """

        self.config.add_layout(
            'l1', view=Layout1, context=Context1)
        self.config.add_layout(
            'l1', view=Layout2, context=Context2, parent='l1')
        self.config.add_layout(
            'l3', view=Layout3, context=Context3, parent='l1')

        root = Root()
        context1 = Context1()
        context2 = Context2()
        context3 = Context3()

        context1.__parent__ = root
        context2.__parent__ = context1
        context3.__parent__ = context2

        from player.layout_impl import query_layout_chain
        chain = query_layout_chain(root, context1, self.request, 'l1')

        self.assertEqual(len(chain), 1)
        self.assertIs(chain[0][0].original, Layout1)

        chain = query_layout_chain(root, context2, self.request, 'l1')

        self.assertEqual(len(chain), 2)
        self.assertIs(chain[0][0].original, Layout2)
        self.assertIs(chain[1][0].original, Layout1)

        chain = query_layout_chain(root, context3, self.request, 'l3')

        self.assertEqual(len(chain), 3)
        self.assertIs(chain[0][0].original, Layout3)
        self.assertIs(chain[1][0].original, Layout2)
        self.assertIs(chain[2][0].original, Layout1)
예제 #3
0
    def test_query_layout_chain(self, m):
        from player.layout_impl import query_layout_chain

        m.return_value = (None, None)
        chain = query_layout_chain(Root(), Context(), self.request)

        self.assertEqual([], chain)
예제 #4
0
    def test_query_layout_chain(self, m):
        from player.layout_impl import query_layout_chain

        m.return_value = (None, None)
        chain = query_layout_chain(Root(), Context(), self.request)

        self.assertEqual([], chain)