def testGetCurrentFolder(self):
        # If context is a folder, then the folder is returned
        view = Plone(self.folder, self.app.REQUEST)
        self.assertEqual(view.getCurrentFolder(), self.folder)

        # If context is not a folder, then the parent is returned
        # A bit crude ... we need to make sure our memos don't stick in the
        # tests
        self._invalidateRequestMemoizations()
        view = Plone(self.folder.test, self.app.REQUEST)
        self.assertEqual(view.getCurrentFolder(), self.folder)

        # The real container is returned regardless of context
        self._invalidateRequestMemoizations()
        view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST)
        self.assertEqual(view.getCurrentFolder(), self.folder)

        # A non-structural folder does not count as a folder`
        f = dummy.NonStructuralFolder('ns_folder')
        self.folder._setObject('ns_folder', f)
        self._invalidateRequestMemoizations()
        view = Plone(self.folder.ns_folder, self.app.REQUEST)
        self.assertEqual(view.getCurrentFolder(), self.folder)

        # And even a structural folder that is used as a default page
        # returns its parent
        self.folder.setDefaultPage('ns_folder')
        self._invalidateRequestMemoizations()
        view = Plone(self.folder.ns_folder, self.app.REQUEST)
        self.assertEqual(view.getCurrentFolder(), self.folder)
 def testNonStructuralFolderHidesChildren(self):
     # Make sure NonStructuralFolders act as if parentMetaTypesNotToQuery
     # is set.
     f = dummy.NonStructuralFolder('ns_folder')
     self.portal.folder1._setObject('ns_folder', f)
     self.portal.portal_catalog.reindexObject(self.portal.folder1.ns_folder)
     self.portal.portal_catalog.reindexObject(self.portal.folder1)
     view = self.renderer(self.portal.folder1.ns_folder)
     tree = view.getNavTree()
     self.assertEqual(tree['children'][3]['children'][3]['item'].getPath(),
                             '/plone/folder1/ns_folder')
     self.assertEqual(len(tree['children'][3]['children'][3]['children']), 0)
 def testNonStructuralFolderHidesChildren(self):
     # Make sure NonStructuralFolders act as if parent_types_not_to_query
     # is set.
     f = dummy.NonStructuralFolder('ns_folder')
     self.folder._setObject('ns_folder', f)
     self.portal.portal_catalog.reindexObject(self.folder.ns_folder)
     self.portal.portal_catalog.reindexObject(self.folder)
     self.navigation_settings.root = '/Members/test_user_1_'
     view = self.view_class(self.folder.ns_folder, self.request)
     tree = view.navigationTree()
     self.assertEqual(tree['children'][0]['item'].getPath(),
                      '/plone/Members/test_user_1_/ns_folder')
     self.assertEqual(len(tree['children'][0]['children']), 0)
 def testNonStructuralFolderHidesChildren(self):
     # Make sure NonStructuralFolders act as if parentMetaTypesNotToQuery
     # is set.
     f = dummy.NonStructuralFolder('ns_folder')
     self.folder._setObject('ns_folder', f)
     self.portal.portal_catalog.reindexObject(self.folder.ns_folder)
     self.portal.portal_catalog.reindexObject(self.folder)
     ntp = self.portal.portal_properties.navtree_properties
     ntp.manage_changeProperties(root='/Members/test_user_1_')
     view = self.view_class(self.folder.ns_folder, self.request)
     tree = view.navigationTree()
     self.assertEqual(tree['children'][0]['item'].getPath(),
                      '/plone/Members/test_user_1_/ns_folder')
     self.assertEqual(len(tree['children'][0]['children']), 0)
Example #5
0
 def testNonStructuralFolderHidesChildren(self):
     base = self.portal.absolute_url()
     # Make sure NonStructuralFolders act as if parent_types_not_to_query
     # is set.
     f = dummy.NonStructuralFolder("ns_folder")
     self.portal.folder1._setObject("ns_folder", f)
     self.portal.portal_catalog.reindexObject(self.portal.folder1.ns_folder)
     self.portal.portal_catalog.reindexObject(self.portal.folder1)
     view = self.renderer(
         self.portal.folder1.ns_folder, opts(includeTop=True, topLevel=0)
     )
     tree = view.getNavTree()
     self.assertEqual(
         tree["items"][3]["items"][3]["href"],
         "%s/folder1/ns_folder" % base,
     )
     self.assertEqual(len(tree["items"][3]["items"][3]["items"]), 0)
 def testIsFolderOrFolderDefaultPage(self):
     # an actual folder whould return true
     view = Plone(self.folder, self.app.REQUEST)
     self.assertTrue(view.isFolderOrFolderDefaultPage())
     # But not a document
     self._invalidateRequestMemoizations()
     view = Plone(self.folder.test, self.app.REQUEST)
     self.assertFalse(view.isFolderOrFolderDefaultPage())
     # Unless we make it the default view
     self.folder.setDefaultPage('test')
     self._invalidateRequestMemoizations()
     view = Plone(self.folder.test, self.app.REQUEST)
     self.assertTrue(view.isFolderOrFolderDefaultPage())
     # And if we have a non-structural folder it should not be true
     f = dummy.NonStructuralFolder('ns_folder')
     self.folder._setObject('ns_folder', f)
     self._invalidateRequestMemoizations()
     view = Plone(self.folder.ns_folder, self.app.REQUEST)
     self.assertFalse(view.isFolderOrFolderDefaultPage())
 def testIsStructuralFolderWithNonStructuralFolder(self):
     f = dummy.NonStructuralFolder('ns_folder')
     self.assertFalse(Plone(f, self.app.REQUEST).isStructuralFolder())
 def test_is_folderishWithNonStructuralFolder(self):
     f = dummy.NonStructuralFolder('ns_folder')
     self.assertFalse(is_folderish(f)())
Example #9
0
 def test_is_folderishWithNonStructuralFolder(self):
     f = dummy.NonStructuralFolder('ns_folder')
     self.failIf(is_folderish(f)())