def test_menu_link_external(): menu = MenuFactory(slug='main') menu_item = MenuItemFactory(menu=menu, slug='present') menu_item.link = Link.objects.create_external_link( 'http://www.bbc.co.uk/', 'News' ) menu_item.save() assert menu_item.get_link() == 'http://www.bbc.co.uk/'
def test_init_menuitem_update(): menu = MenuFactory(slug=Menu.NAVIGATION) item = MenuItemFactory(menu=menu, slug='main-1', title='x', order=0) assert item.menu == menu assert item.slug == 'main-1' assert item.title == 'x' assert item.order == 0 assert item.get_link() == '#' link = Link.objects.create_external_link('http://www.bbc.co.uk/', 'BBC') item = MenuItem.objects.init_menuitem( menu=menu, slug='main-1', title='test', order=1, link=link ) assert item.menu == menu assert item.slug == 'main-1' assert item.title == 'test' assert item.order == 1 assert item.get_link() == 'http://www.bbc.co.uk/'
def test_menu_link_internal(): menu = MenuFactory(slug='main') page = PageFactory(slug='current', slug_menu='day') menu_item = MenuItemFactory(menu=menu, slug='present') menu_item.link = Link.objects.create_internal_link( Url.objects.init_page_url(page) ) menu_item.save() menu_item.refresh_from_db() assert menu_item.get_link() == '/current/day/'
def test_menu_link_none(): menu = MenuFactory(slug='main') menu_item = MenuItemFactory(menu=menu, slug='present') assert 1 == len(Menu.objects.navigation_menu_items()) assert menu_item.get_link() == '#'