def testBottomLevelZeroNoLimitRendering(self):
        """Test that bottomLevel=0 means no limit for bottomLevel."""

        # first we set a high integer as bottomLevel to simulate "no limit"
        view = self.renderer(self.portal.folder2,
                             assignment=navigation.Assignment(bottomLevel=99,
                                                              topLevel=0))
        a = view.render()

        # now set bottomLevel to 0 -> outcome should be the same
        view = self.renderer(self.portal.folder2,
                             assignment=navigation.Assignment(bottomLevel=0,
                                                              topLevel=0))
        b = view.render()

        self.assertEqual(a, b)
Пример #2
0
    def testINavigationRootWithRelativeRootSet(self):
        """test that navigation portlet uses relative root set by user
           even in INavigationRoot case.
        """
        self.assertFalse(INavigationRoot.providedBy(self.portal.folder1))

        # make folder1 as navigation root
        directlyProvides(self.portal.folder1, INavigationRoot)
        self.assertTrue(INavigationRoot.providedBy(self.portal.folder1))

        # add two nested subfolders in folder1
        self.portal.folder1.invokeFactory('Folder', 'folder1_1')
        self.portal.folder1.folder1_1.invokeFactory('Folder', 'folder1_1_1')

        # make a navigation portlet with navigation root set
        assignment = navigation.Assignment(bottomLevel=0, topLevel=0,
                root_uid=self.portal.folder1.folder1_1.UID())
        portlet = self.renderer(self.portal.folder1.folder1_1,
                assignment=assignment)

        # check there is a portlet
        self.assertTrue(portlet.available)

        # check that portlet root is actually the one specified
        root = portlet.getNavRoot()
        self.assertEqual(root.getId(), 'folder1_1')

        # check that portlet tree actually includes children
        tree = portlet.getNavTree()
        self.assertEqual(len(tree['children']), 1)
        self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder1/folder1_1/folder1_1_1')
Пример #3
0
    def testInvokeEditView(self):
        mapping = PortletAssignmentMapping()
        request = self.folder.REQUEST

        mapping['foo'] = navigation.Assignment()
        editview = getMultiAdapter((mapping['foo'], request), name='edit')
        self.assertTrue(isinstance(editview, navigation.EditForm))
Пример #4
0
 def __call__(self, top_level=1):
     data = navigation.Assignment(topLevel=int(top_level)).__of__(self)
     renderer = navigation.Renderer(self.context, self.request, self, None,
                                    data)
     renderer = renderer.__of__(self.context)
     renderer.update()
     return renderer.render()
Пример #5
0
 def testOutsideRoot(self):
     view = self.renderer(self.portal.folder1,
                          assignment=navigation.Assignment(root='/folder2'))
     tree = view.getNavTree()
     self.assertTrue(tree)
     self.assertEqual(tree['children'][0]['item'].getPath(),
                      '/plone/folder2/doc21')
Пример #6
0
 def testTopLevel(self):
     view = self.renderer(self.portal.folder2.file21,
                          assignment=navigation.Assignment(topLevel=1))
     tree = view.getNavTree()
     self.assertTrue(tree)
     self.assertEqual(tree['children'][-1]['item'].getPath(),
                      '/plone/folder2/file21')
 def testRootDoesNotExist(self):
     view = self.renderer(self.portal.folder2.file21,
                          assignment=navigation.Assignment(
                              root_uid='DOESNT_EXIST', topLevel=0))
     tree = view.getNavTree()
     self.assertTrue(tree)
     self.assertEqual(len(tree['children']), 6)
Пример #8
0
 def testHeadingLinkRooted(self):
     """
     See that heading link points to a content item if root selected, otherwise sitemap.
     """
     view = self.renderer(self.portal.folder2, assignment=navigation.Assignment(topLevel=0, root_uid=self.portal.folder2.UID()))
     link = view.heading_link_target()
     self.assertEqual(link, 'http://nohost/plone/folder2')
Пример #9
0
    def renderer(self, context=None, request=None, view=None, manager=None, assignment=None):
        context = context or self.portal
        request = request or self.request
        view = view or self.portal.restrictedTraverse('@@plone')
        manager = manager or getUtility(IPortletManager, name='plone.leftcolumn', context=self.portal)
        assignment = assignment or navigation.Assignment(topLevel=0)

        return getMultiAdapter((context, request, view, manager, assignment), IPortletRenderer)
Пример #10
0
    def test_invoke_edit_view(self):
        # NOTE: This test can be removed if the portlet has no edit form
        mapping = PortletAssignmentMapping()
        request = self.folder.REQUEST

        mapping['foo'] = navigation.Assignment()
        editview = getMultiAdapter((mapping['foo'], request), name='edit')
        self.failUnless(isinstance(editview, navigation.EditForm))
Пример #11
0
 def testNavRootWithUnicodeNavigationRoot(self):
     self.portal.folder2.invokeFactory('Folder', 'folder21')
     self.portal.folder2.folder21.invokeFactory('Document', 'doc211')
     view = self.renderer(self.portal.folder2.folder21,
         assignment=navigation.Assignment(topLevel=1, root_uid=self.portal.folder2.UID()))
     self.assertEqual(view.getNavRootPath(), '/plone/folder2/folder21')
     self.assertEqual(view.getNavRoot().absolute_url(),
                      self.portal.folder2.folder21.absolute_url())
Пример #12
0
 def testRootDoesNotExist(self):
     view = self.renderer(self.portal.folder2.file21,
                          assignment=navigation.Assignment(root='/dodo',
                                                           topLevel=0))
     tree = view.getNavTree()
     self.failUnless(tree)
     self.assertEqual(tree.get('item', None), None)
     self.assertEqual(len(tree['children']), 0)
Пример #13
0
 def testRootIsCurrent(self):
     view = self.renderer(
         self.portal.folder2,
         assignment=navigation.Assignment(currentFolderOnly=True))
     tree = view.getNavTree()
     self.failUnless(tree)
     self.assertEqual(tree['children'][0]['item'].getPath(),
                      '/plone/folder2/doc21')
Пример #14
0
    def testRootIsCurrentWithFolderishDefaultPage(self):
        self.portal.folder2.invokeFactory('Folder', 'folder21')
        self.portal.folder2.setDefaultPage('folder21')

        view = self.renderer(self.portal.folder2.folder21, assignment=navigation.Assignment(currentFolderOnly=True))
        tree = view.getNavTree()
        self.assertTrue(tree)
        self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')
Пример #15
0
 def testRootIsNotPortal(self):
     view = self.renderer(self.portal.folder2.file21,
                          assignment=navigation.Assignment(root='/folder2',
                                                           topLevel=0))
     tree = view.getNavTree()
     self.failUnless(tree)
     self.assertEqual(tree['children'][0]['item'].getPath(),
                      '/plone/folder2/doc21')
Пример #16
0
 def testHeadingLinkRootedItemGone(self):
     """
     See that heading link points to a content item which do not exist
     """
     view = self.renderer(self.portal.folder2, assignment=navigation.Assignment(topLevel=0, root_uid="DOESNT_EXIST"))
     link = view.heading_link_target()
     # Points to the site root if the item is gone
     self.assertEqual(link, "http://nohost/plone/sitemap")
Пример #17
0
 def testNoRootSet(self):
     view = self.renderer(self.portal.folder2.file21,
                          assignment=navigation.Assignment(root_uid='',
                                                           topLevel=0))
     tree = view.getNavTree()
     self.assertTrue(tree)
     self.assertEqual(tree['children'][-1]['item'].getPath(),
                      '/plone/folder2')
Пример #18
0
 def testBottomLevelStopsAtFolder(self):
     view = self.renderer(self.portal.folder2,
                          assignment=navigation.Assignment(bottomLevel=1,
                                                           topLevel=0))
     tree = view.getNavTree()
     self.failUnless(tree)
     self.assertEqual(tree['children'][-1]['item'].getPath(),
                      '/plone/folder2')
     self.assertEqual(len(tree['children'][-1]['children']), 0)
Пример #19
0
 def testTopLevelWithPortalFactory(self):
     id = self.portal.generateUniqueId('Document')
     typeName = 'Document'
     newObject = self.portal.folder1.restrictedTraverse('portal_factory/' +
                                                        typeName + '/' + id)
     # Will raise a KeyError unless bug is fixed
     view = self.renderer(newObject,
                          assignment=navigation.Assignment(topLevel=1))
     view.getNavTree()
Пример #20
0
 def testTopLevelWithNavigationRoot(self):
     self.portal.folder2.invokeFactory('Folder', 'folder21')
     self.portal.folder2.folder21.invokeFactory('Document', 'doc211')
     view = self.renderer(self.portal.folder2.folder21,
         assignment=navigation.Assignment(topLevel=1, root_uid=self.portal.folder2.UID()))
     tree = view.getNavTree()
     self.assertTrue(tree)
     self.assertEqual(len(tree['children']), 1)
     self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/folder21/doc211')
Пример #21
0
 def create_portlet(self):
     portlet = navigation.Assignment(**self.properties)
     manager = getUtility(IPortletManager,
                          name=u'plone.leftcolumn',
                          context=self.context)
     assignments = getMultiAdapter((self.context, manager),
                                   IPortletAssignmentMapping,
                                   context=self.context)
     assignments['navigation'] = portlet
Пример #22
0
    def testRenderer(self):
        context = self.folder
        request = self.folder.REQUEST
        view = self.folder.restrictedTraverse('@@plone')
        manager = getUtility(IPortletManager, name='plone.leftcolumn', context=self.portal)
        assignment = navigation.Assignment()

        renderer = getMultiAdapter((context, request, view, manager, assignment), IPortletRenderer)
        self.assertTrue(isinstance(renderer, navigation.Renderer))
Пример #23
0
    def testPrunedRootNode(self):
        ntp=self.portal.portal_properties.navtree_properties
        ntp.manage_changeProperties(parentMetaTypesNotToQuery=['Folder'])

        assignment = navigation.Assignment(topLevel=0)
        assignment.topLevel = 1
        view = self.renderer(self.portal.folder1, assignment=assignment)
        tree = view.getNavTree()
        self.assertTrue(tree)
        self.assertEqual(len(tree['children']), 0)
Пример #24
0
    def testPrunedRootNode(self):
        registry = self.portal.portal_registry
        registry['plone.parent_types_not_to_query'] = [u'Folder']

        assignment = navigation.Assignment(topLevel=0)
        assignment.topLevel = 1
        view = self.renderer(self.portal.folder1, assignment=assignment)
        tree = view.getNavTree()
        self.assertTrue(tree)
        self.assertEqual(len(tree['children']), 0)
Пример #25
0
 def testIncludeTopWithoutNavigationRoot(self):
     self.portal.folder2.invokeFactory('Folder', 'folder21')
     self.portal.folder2.folder21.invokeFactory('Document', 'doc211')
     view = self.renderer(self.portal.folder2.folder21,
         assignment=navigation.Assignment(topLevel=0, root_uid=None, includeTop=True))
     tree = view.getNavTree()
     self.failUnless(tree)
     self.failUnless(view.root_is_portal())
     self.assertEqual(len(tree['children']), 6)
     self.assertEqual(view.getNavRootPath(), '/plone')
Пример #26
0
 def testShowAllParentsOverridesBottomLevel(self):
     view = self.renderer(self.portal.folder2.file21, assignment=navigation.Assignment(bottomLevel=1, topLevel=0))
     tree = view.getNavTree()
     self.assertTrue(tree)
     # Note: showAllParents makes sure we actually return items on the,
     # path to the context, but the portlet will not display anything
     # below bottomLevel.
     self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
     self.assertEqual(len(tree['children'][-1]['children']), 1)
     self.assertEqual(tree['children'][-1]['children'][0]['item'].getPath(), '/plone/folder2/file21')
Пример #27
0
    def testBottomLevelZeroNoLimit(self):
        """Test that bottomLevel=0 means no limit for bottomLevel."""

        # first we set a high integer as bottomLevel to simulate "no limit"
        view = self.renderer(self.portal.folder2,
                             assignment=navigation.Assignment(bottomLevel=99,
                                                              topLevel=0))
        tree = view.getNavTree()
        self.failUnless(tree)
        self.assertEqual(tree['children'][-1]['children'][0]['item'].getPath(),
                         '/plone/folder2/doc21')

        # now set bottomLevel to 0 -> outcome should be the same
        view = self.renderer(self.portal.folder2,
                             assignment=navigation.Assignment(bottomLevel=0,
                                                              topLevel=0))
        tree = view.getNavTree()
        self.failUnless(tree)
        self.assertEqual(tree['children'][-1]['children'][0]['item'].getPath(),
                         '/plone/folder2/doc21')
Пример #28
0
    def testPrunedRootNodeShowsAllParents(self):
        ntp=self.portal.portal_properties.navtree_properties
        ntp.manage_changeProperties(parentMetaTypesNotToQuery=['Folder'])

        assignment = navigation.Assignment(topLevel=0)
        assignment.topLevel = 1
        view = self.renderer(self.portal.folder1.doc11, assignment=assignment)
        tree = view.getNavTree()
        self.assertTrue(tree)
        self.assertEqual(len(tree['children']), 1)
        self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder1/doc11')
Пример #29
0
    def testPrunedRootNodeShowsAllParents(self):
        registry = self.portal.portal_registry
        registry['plone.parent_types_not_to_query'] = [u'Folder']

        assignment = navigation.Assignment(topLevel=0)
        assignment.topLevel = 1
        view = self.renderer(self.portal.folder1.doc11, assignment=assignment)
        tree = view.getNavTree()
        self.assertTrue(tree)
        self.assertEqual(len(tree['children']), 1)
        self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder1/doc11')
Пример #30
0
 def testMultipleTopLevelWithNavigationRoot(self):
     # See bug 9405
     # http://dev.plone.org/plone/ticket/9405
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     self.portal.invokeFactory('Folder', 'abc')
     self.portal.invokeFactory('Folder', 'abcde')
     self.portal.abc.invokeFactory('Folder', 'down_abc')
     self.portal.abcde.invokeFactory('Folder', 'down_abcde')
     view1 = self.renderer(self.portal.abc, assignment=navigation.Assignment(topLevel=0, root_uid=self.portal.abc.UID()))
     view2 = self.renderer(self.portal.abc, assignment=navigation.Assignment(topLevel=0, root_uid=self.portal.abcde.UID()))
     tree1 = view1.getNavTree()
     tree2 = view2.getNavTree()
     self.assertEqual(len(tree1['children']), 1)
     self.assertEqual(len(tree2['children']), 1)
     view1 = self.renderer(self.portal.abcde, assignment=navigation.Assignment(topLevel=0, root_uid=self.portal.abc.UID()))
     view2 = self.renderer(self.portal.abcde, assignment=navigation.Assignment(topLevel=0, root_uid=self.portal.abcde.UID()))
     tree1 = view1.getNavTree()
     tree2 = view2.getNavTree()
     self.assertEqual(len(tree2['children']), 1)
     self.assertEqual(len(tree1['children']), 1)