Testing post in menu depending if category is present

This commit is contained in:
Iacopo Spalletti 2016-02-04 06:13:35 +01:00
parent 1939ec7919
commit 178b9bdcc7

View file

@ -37,7 +37,7 @@ class MenuTest(BaseTest):
""" """
Tests if all categories are present in the menu Tests if all categories are present in the menu
""" """
self.get_posts() posts = self.get_posts()
self.get_pages() self.get_pages()
for lang in ('en', 'it'): for lang in ('en', 'it'):
@ -47,6 +47,16 @@ class MenuTest(BaseTest):
nodes_url = set([node.url for node in nodes]) nodes_url = set([node.url for node in nodes])
cats_url = set([cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang)]) cats_url = set([cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang)])
self.assertTrue(cats_url.issubset(nodes_url)) self.assertTrue(cats_url.issubset(nodes_url))
menu_pool.clear()
posts[0].categories.clear()
for lang in ('en', 'it'):
request = self.get_page_request(None, self.user, r'/%s/page-two/' % lang)
with smart_override(lang):
nodes = menu_pool.get_nodes(request, namespace='BlogCategoryMenu')
nodes_url = set([node.url for node in nodes])
self.assertFalse(posts[0].get_absolute_url() in nodes_url)
self.assertTrue(posts[1].get_absolute_url() in nodes_url)
def test_menu_options(self): def test_menu_options(self):
""" """