def test_menu_cache_key_on_communes(self):
     communes = getattr(self.portal, 'commune')
     viewlet = CpskinMenuViewlet(communes, self.request, None, None)
     viewlet.update()
     key = cache_key(viewlet.superfish_portal_tabs, viewlet)
     self.assertTrue(key.startswith('menu.'))
     self.assertTrue(key.endswith(IUUID(communes)))
 def test_menu_cache_usage_test_fail(self):
     item = self.portal.restrictedTraverse('commune/services_communaux')
     viewlet = CpskinMenuViewlet(item, self.request, None, None)
     viewlet.update()
     self.assertEqual(get_cache_miss(), 0)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
 def test_menu_cache_key_on_communes_subitem(self):
     item = self.portal.restrictedTraverse('commune/services_communaux')
     communes = getattr(self.portal, 'commune')
     viewlet = CpskinMenuViewlet(item, self.request, None, None)
     viewlet.update()
     key = cache_key(viewlet.superfish_portal_tabs, viewlet)
     self.assertTrue(key.startswith('menu.'))
     self.assertTrue(key.endswith(IUUID(communes)))
Example #4
0
    def test_menu_lp_portal_tabs(self):
        """Root page + load page menu actived should not return menus"""
        viewlet = CpskinMenuViewlet(self.portal, self.request, None, None)
        viewlet.update()

        self.assertTrue(viewlet.is_homepage)
        menus = viewlet.superfish_portal_tabs()

        self.assertEqual(len(menus), 0)
 def test_object_publication_invalidates_menu(self):
     item = self.portal.restrictedTraverse('commune/services_communaux')
     viewlet = CpskinMenuViewlet(item, self.request, None, None)
     viewlet.update()
     self.assertEqual(get_cache_miss(), 0)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     api.content.transition(item, 'publish')
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 2)
 def test_objet_modification_invalidates_menu(self):
     item = self.portal.restrictedTraverse('commune/services_communaux')
     viewlet = CpskinMenuViewlet(item, self.request, None, None)
     viewlet.update()
     self.assertEqual(get_cache_miss(), 0)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     item.setTitle('Test Cache Invalidation')
     item.processForm()
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 2)
    def test_menu_cache_invalidate_another_menu(self):
        item = self.portal.restrictedTraverse('commune/services_communaux')
        commune = self.portal.restrictedTraverse('commune/services_communaux')
        viewlet = CpskinMenuViewlet(item, self.request, None, None)
        viewlet.update()

        self.assertEqual(get_cache_miss(), 0)
        viewlet.superfish_portal_tabs()
        self.assertEqual(get_cache_miss(), 1)

        loisirs = self.portal.restrictedTraverse('loisirs')
        invalidate_menu(loisirs)
        viewlet.superfish_portal_tabs()
        self.assertEqual(get_cache_miss(), 1)

        invalidate_menu(commune)
        viewlet.superfish_portal_tabs()
        self.assertEqual(get_cache_miss(), 2)
 def test_menu_cache_key_on_root(self):
     viewlet = CpskinMenuViewlet(self.portal, self.request, None, None)
     viewlet.update()
     key = cache_key(viewlet.superfish_portal_tabs, viewlet)
     self.assertTrue(key.startswith('menu.'))
     self.assertTrue(key.endswith(IUUID(self.portal)))
 def test_menu_portal_tabs(self):
     viewlet = CpskinMenuViewlet(self.portal, self.request, None, None)
     viewlet.update()
     self.assertTrue(viewlet.is_homepage)
     menus = viewlet.superfish_portal_tabs()
     self.assertEqual(len(menus), 2)
 def test_object_rename_invalidates_menu(self):
     item = self.portal.restrictedTraverse('commune/services_communaux')
     commune = self.portal.restrictedTraverse('commune')
     viewlet = CpskinMenuViewlet(commune, self.request, None, None)
     viewlet.update()
     self.assertEqual(get_cache_miss(), 0)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     api.content.rename(item, new_id='sc')
     viewlet.update()
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 2)
 def test_object_moved_invalidates_menus(self):
     item = self.portal.restrictedTraverse('commune/services_communaux')
     commune = self.portal.restrictedTraverse('commune')
     loisirs = self.portal.restrictedTraverse('loisirs')
     viewlet = CpskinMenuViewlet(commune, self.request, None, None)
     viewlet.update()
     self.assertEqual(get_cache_miss(), 0)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 1)
     viewlet_loisirs = CpskinMenuViewlet(loisirs, self.request, None, None)
     viewlet_loisirs.update()
     self.assertEqual(get_cache_miss(), 1)
     viewlet_loisirs.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 2)
     viewlet_loisirs.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 2)
     api.content.move(item, loisirs)
     viewlet.update()
     viewlet_loisirs.update()
     self.assertEqual(get_cache_miss(), 2)
     viewlet_loisirs.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 3)
     viewlet.superfish_portal_tabs()
     self.assertEqual(get_cache_miss(), 4)