def test_simple_app(self): Menu(self.app) @self.app.route('/test') @register_menu(self.app, '.', 'Test') def test(): return 'test' @self.app.route('/level2') @register_menu(self.app, 'level2', 'Level 2') def level2(): return 'level2' @self.app.route('/level3') @register_menu(self.app, 'level2.level3', 'Level 3', order=2) def level3(): return 'level3' @self.app.route('/level3B') @register_menu(self.app, 'level2.level3B', 'Level 3B', order=1) def level3B(): return 'level3B' with self.app.test_client() as c: c.get('/test') assert request.endpoint == 'test' assert current_menu.url == '/test' assert current_menu.text == 'Test' assert current_menu.active self.assertEqual(current_menu.submenu('level2').text, 'Level 2') assert not current_menu.submenu('level2').active assert current_menu.submenu('missing', auto_create=False) is None assert len(current_menu.list_path('.', '.level2.level3')) == 3 assert current_menu.list_path('.', 'missing') is None assert current_menu.list_path('missing', '.level2.level3') is None assert current_menu.list_path('level2.level3B', 'level2.level3') is None with self.app.test_client() as c: c.get('/level2') assert current_menu.submenu('level2').active with self.app.test_client() as c: c.get('/level3') assert current_menu.submenu('.level2.level3').active assert current_menu.submenu('level2.level3').active assert not current_menu.has_active_child(recursive=False) assert current_menu.has_active_child() assert current_menu.submenu('level2').has_active_child( recursive=False) assert current_menu.submenu('level2').has_active_child() item_2 = current_menu.submenu('level2.level3') item_1 = current_menu.submenu('level2.level3B') assert item_1.order < item_2.order assert item_1 == current_menu.submenu('level2').children[0] assert item_2 == current_menu.submenu('level2').children[1]
def breadcrumbs(): """Backend function for breadcrumbs proxy. :return: A list of breadcrumbs. """ # Construct breadcrumbs using their dynamic lists breadcrumb_list = [] for entry in current_menu.list_path( breadcrumb_root_path, current_path) or []: breadcrumb_list += entry.dynamic_list return breadcrumb_list
def breadcrumbs(): """Backend function for breadcrumbs proxy. :return: A list of breadcrumbs. """ # Construct breadcrumbs using their dynamic lists breadcrumb_list = [] for entry in current_menu.list_path(breadcrumb_root_path, current_path) or []: breadcrumb_list += entry.dynamic_list return breadcrumb_list