Back to index

plone3  3.1.7
Public Member Functions
plone.app.portlets.tests.test_navigation_portlet.TestRenderer Class Reference
Inheritance diagram for plone.app.portlets.tests.test_navigation_portlet.TestRenderer:
Inheritance graph
[legend]
Collaboration diagram for plone.app.portlets.tests.test_navigation_portlet.TestRenderer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def renderer
def populateSite
def testCreateNavTree
def testCreateNavTreeCurrentItem
def testNavTreeExcludesItemsWithExcludeProperty
def testShowAllParentsOverridesNavTreeExcludesItemsWithExcludeProperty
def testNavTreeExcludesItemsInIdsNotToList
def testShowAllParentsOverridesNavTreeExcludesItemsInIdsNotToList
def testNavTreeExcludesDefaultPage
def testNavTreeMarksParentMetaTypesNotToQuery
def testCreateNavTreeWithLink
def testNonStructuralFolderHidesChildren
def testTopLevel
def testTopLevelWithContextAboveLevel
def testTopLevelTooDeep
def testTopLevelWithNavigationRoot
def testTopLevelWithPortalFactory
def testShowAllParentsOverridesBottomLevel
def testBottomLevelStopsAtFolder
def testNoRootSet
def testRootIsPortal
def testRootIsNotPortal
def testRootDoesNotExist
def testAboveRoot
def testOutsideRoot
def testRootIsCurrent
def testRootIsCurrentWithFolderishDefaultPage
def testCustomQuery
def testStateFiltering
def testPrunedRootNode
def testPrunedRootNodeShowsAllParents
def testIsCurrentParentWithOverlapingNames

Detailed Description

Definition at line 69 of file test_navigation_portlet.py.


Member Function Documentation

Definition at line 71 of file test_navigation_portlet.py.

00071 
00072     def afterSetUp(self):
00073         self.populateSite()
        

Here is the call graph for this function:

Definition at line 83 of file test_navigation_portlet.py.

00083 
00084     def populateSite(self):
00085         self.setRoles(['Manager'])
00086         self.portal.invokeFactory('Document', 'doc1')
00087         self.portal.invokeFactory('Document', 'doc2')
00088         self.portal.invokeFactory('Document', 'doc3')
00089         self.portal.invokeFactory('Folder', 'folder1')
00090         self.portal.invokeFactory('Link', 'link1')
00091         self.portal.link1.setRemoteUrl('http://plone.org')
00092         self.portal.link1.reindexObject()
00093         folder1 = getattr(self.portal, 'folder1')
00094         folder1.invokeFactory('Document', 'doc11')
00095         folder1.invokeFactory('Document', 'doc12')
00096         folder1.invokeFactory('Document', 'doc13')
00097         self.portal.invokeFactory('Folder', 'folder2')
00098         folder2 = getattr(self.portal, 'folder2')
00099         folder2.invokeFactory('Document', 'doc21')
00100         folder2.invokeFactory('Document', 'doc22')
00101         folder2.invokeFactory('Document', 'doc23')
00102         folder2.invokeFactory('File', 'file21')
00103         self.setRoles(['Member'])

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.portlets.tests.test_navigation_portlet.TestRenderer.renderer (   self,
  context = None,
  request = None,
  view = None,
  manager = None,
  assignment = None 
)

Definition at line 74 of file test_navigation_portlet.py.

00074 
00075     def renderer(self, context=None, request=None, view=None, manager=None, assignment=None):
00076         context = context or self.folder
00077         request = request or self.folder.REQUEST
00078         view = view or self.folder.restrictedTraverse('@@plone')
00079         manager = manager or getUtility(IPortletManager, name='plone.leftcolumn', context=self.portal)
00080         assignment = assignment or navigation.Assignment(topLevel=0)
00081 
00082         return getMultiAdapter((context, request, view, manager, assignment), IPortletRenderer)

Here is the call graph for this function:

Definition at line 296 of file test_navigation_portlet.py.

00296 
00297     def testAboveRoot(self):
00298         ntp=self.portal.portal_properties.navtree_properties
00299         ntp.manage_changeProperties(root='/folder2')
00300         view = self.renderer(self.portal)
00301         tree = view.getNavTree()
00302         self.failUnless(tree)
00303         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Here is the call graph for this function:

Definition at line 264 of file test_navigation_portlet.py.

00264 
00265     def testBottomLevelStopsAtFolder(self):
00266         view = self.renderer(self.portal.folder2, assignment=navigation.Assignment(bottomLevel=1, topLevel=0))
00267         tree = view.getNavTree()
00268         self.failUnless(tree)
00269         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
00270         self.assertEqual(len(tree['children'][-1]['children']), 0)
        

Here is the call graph for this function:

Definition at line 104 of file test_navigation_portlet.py.

00104 
00105     def testCreateNavTree(self):
00106         view = self.renderer(self.portal)
00107         tree = view.getNavTree()
00108         self.failUnless(tree)
00109         self.failUnless(tree.has_key('children'))
    

Here is the call graph for this function:

Definition at line 110 of file test_navigation_portlet.py.

00110 
00111     def testCreateNavTreeCurrentItem(self):
00112         # With the context set to folder2 it should return a dict with
00113         # currentItem set to True
00114         view = self.renderer(self.portal.folder2)
00115         tree = view.getNavTree()
00116         self.failUnless(tree)
00117         self.assertEqual(tree['children'][-1]['currentItem'], True)

Here is the call graph for this function:

Definition at line 196 of file test_navigation_portlet.py.

00196 
00197     def testCreateNavTreeWithLink(self):
00198         view = self.renderer(self.portal)
00199         tree = view.getNavTree()
00200         for child in tree['children']:
00201             if child['portal_type'] != 'Link':
00202                 self.failIf(child['item'].getRemoteUrl)
00203             if child['Title'] == 'link1':
00204                 self.failUnlessEqual(child['item'].getRemoteUrl, 'http://plone.org')

Here is the call graph for this function:

Definition at line 325 of file test_navigation_portlet.py.

00325 
00326     def testCustomQuery(self):
00327         # Try a custom query script for the navtree that returns only published
00328         # objects
00329         self.setRoles(['Manager'])
00330         workflow = self.portal.portal_workflow
00331         factory = self.portal.manage_addProduct['PythonScripts']
00332         factory.manage_addPythonScript('getCustomNavQuery')
00333         script = self.portal.getCustomNavQuery
00334         script.ZPythonScript_edit('','return {"review_state":"published"}')
00335         self.assertEqual(self.portal.getCustomNavQuery(),{"review_state":"published"})
00336         view = self.renderer(self.portal.folder2)
00337         tree = view.getNavTree()
00338         self.failUnless(tree)
00339         self.failUnless(tree.has_key('children'))
00340         #Should only contain current object
00341         self.assertEqual(len(tree['children']), 4)
00342         #change workflow for folder1
00343         workflow.doActionFor(self.portal.folder1, 'publish')
00344         self.portal.folder1.reindexObject()
00345         view = self.renderer(self.portal.folder2)
00346         tree = view.getNavTree()
00347         #Should only contain current object and published folder
00348         self.assertEqual(len(tree['children']), 5)

Here is the call graph for this function:

Definition at line 393 of file test_navigation_portlet.py.

00393 
00394     def testIsCurrentParentWithOverlapingNames(self):
00395         self.setRoles(['Manager',])
00396         self.portal.invokeFactory('Folder', 'folder2x')
00397         self.portal.folder2x.invokeFactory('Document', 'doc2x1')
00398         self.setRoles(['Member',])
00399         view = self.renderer(self.portal.folder2x.doc2x1)
00400         tree = view.getNavTree()
00401         self.failUnless(tree)
00402         
00403         folder2x_node = [n for n in tree['children'] if n['path'] == '/plone/folder2x'][0]
00404         self.failUnless(folder2x_node['currentParent'])
00405         
00406         folder2_node = [n for n in tree['children'] if n['path'] == '/plone/folder2'][0]
        self.failIf(folder2_node['currentParent'])

Here is the call graph for this function:

Definition at line 174 of file test_navigation_portlet.py.

00174 
00175     def testNavTreeExcludesDefaultPage(self):
00176         # Make sure that items which are the default page are excluded
00177         self.portal.folder2.setDefaultPage('doc21')
00178         view = self.renderer(self.portal.folder1.doc11)
00179         tree = view.getNavTree()
00180         self.failUnless(tree)
00181         # Ensure that our 'doc21' default page is not in the tree.
00182         self.assertEqual([c for c in tree['children'][-1]['children']
00183                                             if c['item'].getPath()[-5:]=='doc21'],[])

Here is the call graph for this function:

Definition at line 147 of file test_navigation_portlet.py.

00147 
00148     def testNavTreeExcludesItemsInIdsNotToList(self):
00149         # Make sure that items whose ids are in the idsNotToList navTree
00150         # property are not included
00151         ntp=self.portal.portal_properties.navtree_properties
00152         ntp.manage_changeProperties(idsNotToList=['folder2'])
00153         view = self.renderer(self.portal.folder1.doc11)
00154         tree = view.getNavTree()
00155         self.failUnless(tree)
00156         for c in tree['children']:
00157             if c['item'].getPath() == '/plone/folder2':
00158                 self.fail()

Here is the call graph for this function:

Definition at line 118 of file test_navigation_portlet.py.

00118 
00119     def testNavTreeExcludesItemsWithExcludeProperty(self):
00120         # Make sure that items witht he exclude_from_nav property set get
00121         # no_display set to True
00122         self.portal.folder2.setExcludeFromNav(True)
00123         self.portal.folder2.reindexObject()
00124         view = self.renderer(self.portal.folder1.doc11)
00125         tree = view.getNavTree()
00126         self.failUnless(tree)
00127         for c in tree['children']:
00128             if c['item'].getPath() == '/plone/folder2':
00129                 self.fail()

Here is the call graph for this function:

Definition at line 184 of file test_navigation_portlet.py.

00184 
00185     def testNavTreeMarksParentMetaTypesNotToQuery(self):
00186         # Make sure that items whose ids are in the idsNotToList navTree
00187         # property get no_display set to True
00188         view = self.renderer(self.portal.folder2.file21)
00189         tree = view.getNavTree()
00190         self.assertEqual(tree['children'][-1]['show_children'],True)
00191         ntp=self.portal.portal_properties.navtree_properties
00192         ntp.manage_changeProperties(parentMetaTypesNotToQuery=['Folder'])
00193         view = self.renderer(self.portal.folder2.file21)
00194         tree = view.getNavTree()
00195         self.assertEqual(tree['children'][-1]['show_children'],False)

Here is the call graph for this function:

Definition at line 205 of file test_navigation_portlet.py.

00205 
00206     def testNonStructuralFolderHidesChildren(self):
00207         # Make sure NonStructuralFolders act as if parentMetaTypesNotToQuery
00208         # is set.
00209         f = dummy.NonStructuralFolder('ns_folder')
00210         self.folder._setObject('ns_folder', f)
00211         self.portal.portal_catalog.reindexObject(self.folder.ns_folder)
00212         self.portal.portal_catalog.reindexObject(self.folder)
00213         view = self.renderer(self.folder.ns_folder)
00214         tree = view.getNavTree()
00215         self.assertEqual(tree['children'][0]['children'][0]['children'][0]['item'].getPath(),
00216                                 '/plone/Members/test_user_1_/ns_folder')
00217         self.assertEqual(len(tree['children'][0]['children'][0]['children'][0]['children']), 0)

Here is the call graph for this function:

Definition at line 271 of file test_navigation_portlet.py.

00271 
00272     def testNoRootSet(self):
00273         view = self.renderer(self.portal.folder2.file21, assignment=navigation.Assignment(root='', topLevel=0))
00274         tree = view.getNavTree()
00275         self.failUnless(tree)
00276         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
        

Here is the call graph for this function:

Definition at line 304 of file test_navigation_portlet.py.

00304 
00305     def testOutsideRoot(self):
00306         view = self.renderer(self.portal.folder1, assignment=navigation.Assignment(root='/folder2'))
00307         tree = view.getNavTree()
00308         self.failUnless(tree)
00309         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Here is the call graph for this function:

Definition at line 370 of file test_navigation_portlet.py.

00370 
00371     def testPrunedRootNode(self):
00372         ntp=self.portal.portal_properties.navtree_properties
00373         ntp.manage_changeProperties(parentMetaTypesNotToQuery=['Folder'])
00374         
00375         assignment = navigation.Assignment(topLevel=0)
00376         assignment.topLevel = 1
00377         view = self.renderer(self.portal.folder1, assignment=assignment)
00378         tree = view.getNavTree()
00379         self.failUnless(tree)
00380         self.assertEqual(len(tree['children']), 0)
        

Here is the call graph for this function:

Definition at line 381 of file test_navigation_portlet.py.

00381 
00382     def testPrunedRootNodeShowsAllParents(self):
00383         ntp=self.portal.portal_properties.navtree_properties
00384         ntp.manage_changeProperties(parentMetaTypesNotToQuery=['Folder'])
00385         
00386         assignment = navigation.Assignment(topLevel=0)
00387         assignment.topLevel = 1
00388         view = self.renderer(self.portal.folder1.doc11, assignment=assignment)
00389         tree = view.getNavTree()
00390         self.failUnless(tree)
00391         self.assertEqual(len(tree['children']), 1)
00392         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder1/doc11')
    

Here is the call graph for this function:

Definition at line 289 of file test_navigation_portlet.py.

00289 
00290     def testRootDoesNotExist(self):
00291         view = self.renderer(self.portal.folder2.file21, assignment=navigation.Assignment(root='/dodo', topLevel=0))
00292         tree = view.getNavTree()
00293         self.failUnless(tree)
00294         self.assertEqual(tree.get('item', None), None)
00295         self.assertEqual(len(tree['children']), 0)

Here is the call graph for this function:

Definition at line 310 of file test_navigation_portlet.py.

00310 
00311     def testRootIsCurrent(self):
00312         view = self.renderer(self.portal.folder2, assignment=navigation.Assignment(currentFolderOnly=True))
00313         tree = view.getNavTree()
00314         self.failUnless(tree)
00315         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')
        

Here is the call graph for this function:

Definition at line 316 of file test_navigation_portlet.py.

00316 
00317     def testRootIsCurrentWithFolderishDefaultPage(self):
00318         self.portal.folder2.invokeFactory('Folder', 'folder21')
00319         self.portal.folder2.setDefaultPage('folder21')
00320         
00321         view = self.renderer(self.portal.folder2.folder21, assignment=navigation.Assignment(currentFolderOnly=True))
00322         tree = view.getNavTree()
00323         self.failUnless(tree)
00324         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Here is the call graph for this function:

Definition at line 283 of file test_navigation_portlet.py.

00283 
00284     def testRootIsNotPortal(self):
00285         view = self.renderer(self.portal.folder2.file21, assignment=navigation.Assignment(root='/folder2', topLevel=0))
00286         tree = view.getNavTree()
00287         self.failUnless(tree)
00288         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Here is the call graph for this function:

Definition at line 277 of file test_navigation_portlet.py.

00277 
00278     def testRootIsPortal(self):
00279         view = self.renderer(self.portal.folder2.file21, assignment=navigation.Assignment(root='/', topLevel=0))
00280         tree = view.getNavTree()
00281         self.failUnless(tree)
00282         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
        

Here is the call graph for this function:

Definition at line 253 of file test_navigation_portlet.py.

00253 
00254     def testShowAllParentsOverridesBottomLevel(self):
00255         view = self.renderer(self.portal.folder2.file21, assignment=navigation.Assignment(bottomLevel=1, topLevel=0))
00256         tree = view.getNavTree()
00257         self.failUnless(tree)
00258         # Note: showAllParents makes sure we actually return items on the,
00259         # path to the context, but the portlet will not display anything
00260         # below bottomLevel. 
00261         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
00262         self.assertEqual(len(tree['children'][-1]['children']), 1)
00263         self.assertEqual(tree['children'][-1]['children'][0]['item'].getPath(), '/plone/folder2/file21')
        

Here is the call graph for this function:

Definition at line 159 of file test_navigation_portlet.py.

00159 
00160     def testShowAllParentsOverridesNavTreeExcludesItemsInIdsNotToList(self):
00161         # Make sure that items whose ids are in the idsNotToList navTree
00162         # property are not included
00163         ntp=self.portal.portal_properties.navtree_properties
00164         ntp.manage_changeProperties(idsNotToList=['folder2'], showAllParents=True)
00165         view = self.renderer(self.portal.folder2.doc21)
00166         tree = view.getNavTree()
00167         self.failUnless(tree)
00168         found = False
00169         for c in tree['children']:
00170             if c['item'].getPath() == '/plone/folder2':
00171                 found = True
00172                 break
00173         self.failUnless(found)

Here is the call graph for this function:

Definition at line 130 of file test_navigation_portlet.py.

00130 
00131     def testShowAllParentsOverridesNavTreeExcludesItemsWithExcludeProperty(self):
00132         # Make sure that items whose ids are in the idsNotToList navTree
00133         # property are not included
00134         self.portal.folder2.setExcludeFromNav(True)
00135         self.portal.folder2.reindexObject()
00136         ntp=self.portal.portal_properties.navtree_properties
00137         ntp.manage_changeProperties(showAllParents=True)
00138         view = self.renderer(self.portal.folder2.doc21)
00139         tree = view.getNavTree()
00140         self.failUnless(tree)
00141         found = False
00142         for c in tree['children']:
00143             if c['item'].getPath() == '/plone/folder2':
00144                 found = True
00145                 break
00146         self.failUnless(found)

Here is the call graph for this function:

Definition at line 349 of file test_navigation_portlet.py.

00349 
00350     def testStateFiltering(self):
00351         # Test Navtree workflow state filtering
00352         self.setRoles(['Manager'])
00353         workflow = self.portal.portal_workflow
00354         ntp=self.portal.portal_properties.navtree_properties
00355         ntp.manage_changeProperties(wf_states_to_show=['published'])
00356         ntp.manage_changeProperties(enable_wf_state_filtering=True)
00357         view = self.renderer(self.portal.folder2)
00358         tree = view.getNavTree()
00359         self.failUnless(tree)
00360         self.failUnless(tree.has_key('children'))
00361         #Should only contain current object
00362         self.assertEqual(len(tree['children']), 4)
00363         #change workflow for folder1
00364         workflow.doActionFor(self.portal.folder1, 'publish')
00365         self.portal.folder1.reindexObject()
00366         view = self.renderer(self.portal.folder2)
00367         tree = view.getNavTree()
00368         #Should only contain current object and published folder
00369         self.assertEqual(len(tree['children']), 5)
    

Here is the call graph for this function:

Definition at line 218 of file test_navigation_portlet.py.

00218 
00219     def testTopLevel(self):
00220         view = self.renderer(self.portal.folder2.file21, assignment=navigation.Assignment(topLevel=1))
00221         tree = view.getNavTree()
00222         self.failUnless(tree)
00223         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2/file21')

Here is the call graph for this function:

Definition at line 230 of file test_navigation_portlet.py.

00230 
00231     def testTopLevelTooDeep(self):
00232         view = self.renderer(self.portal, assignment=navigation.Assignment(topLevel=5))
00233         tree = view.getNavTree()
00234         self.failUnless(tree)
00235         self.assertEqual(len(tree['children']), 0)

Here is the call graph for this function:

Definition at line 224 of file test_navigation_portlet.py.

00224 
00225     def testTopLevelWithContextAboveLevel(self):
00226         view = self.renderer(self.portal, assignment=navigation.Assignment(topLevel=1))
00227         tree = view.getNavTree()
00228         self.failUnless(tree)
00229         self.assertEqual(len(tree['children']), 0)

Here is the call graph for this function:

Definition at line 236 of file test_navigation_portlet.py.

00236 
00237     def testTopLevelWithNavigationRoot(self):
00238         self.portal.folder2.invokeFactory('Folder', 'folder21')
00239         self.portal.folder2.folder21.invokeFactory('Document', 'doc211')
00240         view = self.renderer(self.portal.folder2.folder21, assignment=navigation.Assignment(topLevel=1, root='/folder2'))
00241         tree = view.getNavTree()
00242         self.failUnless(tree)
00243         self.assertEqual(len(tree['children']), 1)
00244         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/folder21/doc211')

Here is the call graph for this function:

Definition at line 245 of file test_navigation_portlet.py.

00245 
00246     def testTopLevelWithPortalFactory(self):
00247         id=self.portal.generateUniqueId('Document')
00248         typeName='Document'
00249         newObject=self.portal.folder1.restrictedTraverse('portal_factory/' + typeName + '/' + id)
00250         # Will raise a KeyError unless bug is fixed
00251         view = self.renderer(newObject, assignment=navigation.Assignment(topLevel=1))
00252         tree = view.getNavTree()
    

Here is the call graph for this function:


The documentation for this class was generated from the following file: