'Check that menus are dynamically loaded according to the different page the apphook is
attached to'

@override_settings(ROOT_URLCONF='cms.test_utils.project.second_urls_for_apphook_tests')
def test_get_menus(self):

    titles = self.create_base_structure('VariableUrlsApp', ['en', 'de'])
    titles[0].page.reverse_id = 'page1'
    titles[0].page.save()
    cache.clear()
    self.reload_urls()
    menu_pool.discover_menus()
    cache.clear()
    request = self.get_request('/')
    nodes = menu_pool.get_nodes(request)
    nodes_urls = [node.url for node in nodes]
    self.assertTrue((reverse('sample-account') in nodes_urls))
    self.assertFalse(('/en/child_page/page2/' in nodes_urls))
    self.reload_urls()
    self.apphook_clear()
    cache.clear()
    self.reload_urls()
    page2 = create_page('page2', 'nav_playground.html', 'en', created_by=self.superuser, published=True, parent=titles[0].page.get_draft_object().parent, in_navigation=True, apphook='VariableUrlsApp', reverse_id='page2')
    create_title('de', 'de_title', page2, slug='slug')
    page2.publish('de')
    request = self.get_request('/page2/')
    nodes = menu_pool.get_nodes(request)
    nodes_urls = [node.url for node in nodes]
    self.assertTrue((reverse('sample-account') in nodes_urls))
    self.assertTrue((reverse('sample2-root') in nodes_urls))
    self.assertTrue(('/static/fresh/' in nodes_urls))
    self.apphook_clear()
