Пример #1
0
    def test_template_tag(self):
        main_menu = menu.Menu('main')
        node = menu.Node('test', 'Test', url='http://test.com')
        main_menu.register(node)

        output = navutils_tags.render_menu({}, menu=main_menu, user=self.user)

        self.assertHTMLEqual(
            output, """
            <ul class="main-menu">
                <li class="menu-item"><a href="http://test.com">Test</a></li>
            </ul>
            """)
Пример #2
0
    def test_context_available_in_template(self):
        main_menu = menu.Menu('main')
        node = menu.Node('context',
                         'Context',
                         url='http://test-context.com',
                         template='test_app/test_node.html')
        main_menu.register(node)

        output = navutils_tags.render_menu({'foo': 'bar'},
                                           menu=main_menu,
                                           user=self.user)

        self.assertHTMLEqual(
            output, """
            <ul class="main-menu">
                <li class="menu-item"><a href="http://test-context.com">Context bar</a></li>
            </ul>
            """)
Пример #3
0
    def test_menu_can_register_nodes(self):
        main_menu = menu.Menu('main')
        node = menu.Node('test', 'Test', url='http://test.com')
        main_menu.register(node)

        self.assertEqual(main_menu['test'], node)
Пример #4
0
from navutils import menu

main_menu = menu.Menu('main')
menu.register(main_menu)

library = menu.Node(id='library',
                    label='Library',
                    pattern_name='library:media-list')
main_menu.register(library)