Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
CMFPlone.tests.testNavigationView.TestCatalogNavTree Class Reference
Inheritance diagram for CMFPlone.tests.testNavigationView.TestCatalogNavTree:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testNavigationView.TestCatalogNavTree:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
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 testCustomQuery
def testStateFiltering
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 request

Static Public Attributes

 view_class = CatalogNavigationTree

Detailed Description

Definition at line 346 of file testNavigationView.py.


Member Function Documentation

Definition at line 28 of file testNavigationView.py.

00028 
00029     def afterSetUp(self):
00030         self.request = self.app.REQUEST
00031         # Apply a default layer for view lookups to work in Zope 2.9+
00032         setDefaultSkin(self.request)
00033         self.populateSite()
00034         self.setupAuthenticator()
        

Definition at line 30 of file PloneTestCase.py.

00030 
00031     def getAuthenticator(self):
00032         tag = AuthenticatorView('context', 'request').authenticator()
00033         pattern = '<input .*name="(\w+)".*value="(\w+)"'
00034         return match(pattern, tag).groups()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 35 of file testNavigationView.py.

00035 
00036     def populateSite(self):
00037         self.setRoles(['Manager'])
00038         self.portal.invokeFactory('Document', 'doc1')
00039         self.portal.invokeFactory('Document', 'doc2')
00040         self.portal.invokeFactory('Document', 'doc3')
00041         self.portal.invokeFactory('Folder', 'folder1')
00042         self.portal.invokeFactory('Link', 'link1')
00043         self.portal.link1.setRemoteUrl('http://plone.org')
00044         self.portal.link1.reindexObject()
00045         folder1 = getattr(self.portal, 'folder1')
00046         folder1.invokeFactory('Document', 'doc11')
00047         folder1.invokeFactory('Document', 'doc12')
00048         folder1.invokeFactory('Document', 'doc13')
00049         self.portal.invokeFactory('Folder', 'folder2')
00050         folder2 = getattr(self.portal, 'folder2')
00051         folder2.invokeFactory('Document', 'doc21')
00052         folder2.invokeFactory('Document', 'doc22')
00053         folder2.invokeFactory('Document', 'doc23')
00054         folder2.invokeFactory('File', 'file21')
00055         self.setRoles(['Member'])

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.tests.PloneTestCase.PloneTestCase.setRequestMethod (   self,
  method 
) [inherited]
This is a stub now, but in case you want to try
   something fancy on Your Branch (tm), put it here.

Definition at line 26 of file PloneTestCase.py.

00026 
00027     def setRequestMethod(self, method):
00028         self.app.REQUEST.set('REQUEST_METHOD', method)
00029         self.app.REQUEST.method = method

Here is the caller graph for this function:

Definition at line 35 of file PloneTestCase.py.

00035 
00036     def setupAuthenticator(self):
00037         name, token = self.getAuthenticator()
00038         self.app.REQUEST.form[name] = token
00039 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 271 of file testNavigationView.py.

00271 
00272     def testAboveRoot(self):
00273         ntp=self.portal.portal_properties.navtree_properties
00274         ntp.manage_changeProperties(root='/folder2')
00275         view = self.view_class(self.portal, self.request)
00276         tree = view.navigationTree()
00277         self.failUnless(tree)
00278         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Here is the call graph for this function:

Definition at line 229 of file testNavigationView.py.

00229 
00230     def testBottomLevelStopsAtFolder(self):
00231         ntp=self.portal.portal_properties.navtree_properties
00232         ntp.manage_changeProperties(bottomLevel=1)
00233         view = self.view_class(self.portal.folder2, self.request)
00234         tree = view.navigationTree()
00235         self.failUnless(tree)
00236         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
00237         self.assertEqual(len(tree['children'][-1]['children']), 0)
        

Definition at line 56 of file testNavigationView.py.

00056 
00057     def testCreateNavTree(self):
00058         # See if we can create one at all
00059         view = self.view_class(self.portal, self.request)
00060         tree = view.navigationTree()
00061         self.failUnless(tree)
00062         self.failUnless(tree.has_key('children'))

Here is the call graph for this function:

Definition at line 63 of file testNavigationView.py.

00063 
00064     def testCreateNavTreeCurrentItem(self):
00065         # With the context set to folder2 it should return a dict with
00066         # currentItem set to True
00067         view = self.view_class(self.portal.folder2, self.request)
00068         tree = view.navigationTree()
00069         self.failUnless(tree)
00070         self.assertEqual(tree['children'][-1]['currentItem'], True)

Definition at line 149 of file testNavigationView.py.

00149 
00150     def testCreateNavTreeWithLink(self):
00151         view = self.view_class(self.portal, self.request)
00152         tree = view.navigationTree()
00153         for child in tree['children']:
00154             if child['portal_type'] != 'Link':
00155                 self.failIf(child['item'].getRemoteUrl)
00156             if child['Title'] == 'link1':
00157                 self.failUnlessEqual(child['item'].getRemoteUrl, 'http://plone.org')

Here is the call graph for this function:

Definition at line 295 of file testNavigationView.py.

00295 
00296     def testCustomQuery(self):
00297         # Try a custom query script for the navtree that returns only published
00298         # objects
00299         self.portal._delObject('Members')
00300         self.portal._delObject('news')
00301         self.portal._delObject('events')
00302         workflow = self.portal.portal_workflow
00303         factory = self.portal.manage_addProduct['PythonScripts']
00304         factory.manage_addPythonScript('getCustomNavQuery')
00305         script = self.portal.getCustomNavQuery
00306         script.ZPythonScript_edit('','return {"review_state":"published"}')
00307         self.assertEqual(self.portal.getCustomNavQuery(),{"review_state":"published"})
00308         view = self.view_class(self.portal.folder2, self.request)
00309         tree = view.navigationTree()
00310         self.failUnless(tree)
00311         self.failUnless(tree.has_key('children'))
00312         #Should only contain current object
00313         self.assertEqual(len(tree['children']), 1)
00314         #change workflow for folder1
00315         workflow.doActionFor(self.portal.folder1, 'publish')
00316         self.portal.folder1.reindexObject()
00317         view = self.view_class(self.portal.folder2, self.request)
00318         tree = view.navigationTree()
00319         #Should only contain current object and published folder
00320         self.assertEqual(len(tree['children']), 2)

Definition at line 127 of file testNavigationView.py.

00127 
00128     def testNavTreeExcludesDefaultPage(self):
00129         # Make sure that items which are the default page are excluded
00130         self.portal.folder2.setDefaultPage('doc21')
00131         view = self.view_class(self.portal.folder1.doc11, self.request)
00132         tree = view.navigationTree()
00133         self.failUnless(tree)
00134         # Ensure that our 'doc21' default page is not in the tree.
00135         self.assertEqual([c for c in tree['children'][-1]['children']
00136                                             if c['item'].getPath()[-5:]=='doc21'],[])

Definition at line 100 of file testNavigationView.py.

00100 
00101     def testNavTreeExcludesItemsInIdsNotToList(self):
00102         # Make sure that items whose ids are in the idsNotToList navTree
00103         # property are not included
00104         ntp=self.portal.portal_properties.navtree_properties
00105         ntp.manage_changeProperties(idsNotToList=['folder2'])
00106         view = self.view_class(self.portal.folder1.doc11, self.request)
00107         tree = view.navigationTree()
00108         self.failUnless(tree)
00109         for c in tree['children']:
00110             if c['item'].getPath() == '/plone/folder2':
00111                 self.fail()

Here is the call graph for this function:

Definition at line 71 of file testNavigationView.py.

00071 
00072     def testNavTreeExcludesItemsWithExcludeProperty(self):
00073         # Make sure that items witht he exclude_from_nav property set get
00074         # no_display set to True
00075         self.portal.folder2.setExcludeFromNav(True)
00076         self.portal.folder2.reindexObject()
00077         view = self.view_class(self.portal.folder1.doc11, self.request)
00078         tree = view.navigationTree()
00079         self.failUnless(tree)
00080         for c in tree['children']:
00081             if c['item'].getPath() == '/plone/folder2':
00082                 self.fail()

Here is the call graph for this function:

Definition at line 137 of file testNavigationView.py.

00137 
00138     def testNavTreeMarksParentMetaTypesNotToQuery(self):
00139         # Make sure that items whose ids are in the idsNotToList navTree
00140         # property get no_display set to True
00141         view = self.view_class(self.portal.folder2.file21, self.request)
00142         tree = view.navigationTree()
00143         self.assertEqual(tree['children'][-1]['show_children'],True)
00144         ntp=self.portal.portal_properties.navtree_properties
00145         ntp.manage_changeProperties(parentMetaTypesNotToQuery=['Folder'])
00146         view = self.view_class(self.portal.folder2.file21, self.request)
00147         tree = view.navigationTree()
00148         self.assertEqual(tree['children'][-1]['show_children'],False)

Definition at line 158 of file testNavigationView.py.

00158 
00159     def testNonStructuralFolderHidesChildren(self):
00160         # Make sure NonStructuralFolders act as if parentMetaTypesNotToQuery
00161         # is set.
00162         f = dummy.NonStructuralFolder('ns_folder')
00163         self.folder._setObject('ns_folder', f)
00164         self.portal.portal_catalog.reindexObject(self.folder.ns_folder)
00165         self.portal.portal_catalog.reindexObject(self.folder)
00166         view = self.view_class(self.folder.ns_folder, self.request)
00167         tree = view.navigationTree()
00168         self.assertEqual(tree['children'][0]['children'][0]['children'][0]['item'].getPath(),
00169                                 '/plone/Members/test_user_1_/ns_folder')
00170         self.assertEqual(len(tree['children'][0]['children'][0]['children'][0]['children']), 0)

Here is the call graph for this function:

Definition at line 238 of file testNavigationView.py.

00238 
00239     def testNoRootSet(self):
00240         ntp=self.portal.portal_properties.navtree_properties
00241         ntp.manage_changeProperties(root='')
00242         view = self.view_class(self.portal.folder2.file21, self.request)
00243         tree = view.navigationTree()
00244         self.failUnless(tree)
00245         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
        

Definition at line 279 of file testNavigationView.py.

00279 
00280     def testOutsideRoot(self):
00281         ntp=self.portal.portal_properties.navtree_properties
00282         ntp.manage_changeProperties(root='/folder2')
00283         view = self.view_class(self.portal.folder1, self.request)
00284         tree = view.navigationTree()
00285         self.failUnless(tree)
00286         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Definition at line 262 of file testNavigationView.py.

00262 
00263     def testRootDoesNotExist(self):
00264         ntp=self.portal.portal_properties.navtree_properties
00265         ntp.manage_changeProperties(root='/dodo')
00266         view = self.view_class(self.portal.folder2.file21, self.request)
00267         tree = view.navigationTree()
00268         self.failUnless(tree)
00269         self.assertEqual(tree.get('item', None), None)
00270         self.assertEqual(len(tree['children']), 0)

Definition at line 287 of file testNavigationView.py.

00287 
00288     def testRootIsCurrent(self):
00289         ntp=self.portal.portal_properties.navtree_properties
00290         ntp.manage_changeProperties(currentFolderOnlyInNavtree=True)
00291         view = self.view_class(self.portal.folder2, self.request)
00292         tree = view.navigationTree()
00293         self.failUnless(tree)
00294         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Definition at line 254 of file testNavigationView.py.

00254 
00255     def testRootIsNotPortal(self):
00256         ntp=self.portal.portal_properties.navtree_properties
00257         ntp.manage_changeProperties(root='/folder2')
00258         view = self.view_class(self.portal.folder2.file21, self.request)
00259         tree = view.navigationTree()
00260         self.failUnless(tree)
00261         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/doc21')

Definition at line 246 of file testNavigationView.py.

00246 
00247     def testRootIsPortal(self):
00248         ntp=self.portal.portal_properties.navtree_properties
00249         ntp.manage_changeProperties(root='/')
00250         view = self.view_class(self.portal.folder2.file21, self.request)
00251         tree = view.navigationTree()
00252         self.failUnless(tree)
00253         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
        

Definition at line 216 of file testNavigationView.py.

00216 
00217     def testShowAllParentsOverridesBottomLevel(self):
00218         ntp=self.portal.portal_properties.navtree_properties
00219         ntp.manage_changeProperties(bottomLevel=1)
00220         view = self.view_class(self.portal.folder2.file21, self.request)
00221         tree = view.navigationTree()
00222         self.failUnless(tree)
00223         # Note: showAllParents makes sure we actually return items on the,
00224         # path to the context, but the portlet will not display anything
00225         # below bottomLevel. 
00226         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2')
00227         self.assertEqual(len(tree['children'][-1]['children']), 1)
00228         self.assertEqual(tree['children'][-1]['children'][0]['item'].getPath(), '/plone/folder2/file21')
        

Definition at line 112 of file testNavigationView.py.

00112 
00113     def testShowAllParentsOverridesNavTreeExcludesItemsInIdsNotToList(self):
00114         # Make sure that items whose ids are in the idsNotToList navTree
00115         # property are not included
00116         ntp=self.portal.portal_properties.navtree_properties
00117         ntp.manage_changeProperties(idsNotToList=['folder2'], showAllParents=True)
00118         view = self.view_class(self.portal.folder2.doc21, self.request)
00119         tree = view.navigationTree()
00120         self.failUnless(tree)
00121         found = False
00122         for c in tree['children']:
00123             if c['item'].getPath() == '/plone/folder2':
00124                 found = True
00125                 break
00126         self.failUnless(found)

Definition at line 83 of file testNavigationView.py.

00083 
00084     def testShowAllParentsOverridesNavTreeExcludesItemsWithExcludeProperty(self):
00085         # Make sure that items whose ids are in the idsNotToList navTree
00086         # property are not included
00087         self.portal.folder2.setExcludeFromNav(True)
00088         self.portal.folder2.reindexObject()
00089         ntp=self.portal.portal_properties.navtree_properties
00090         ntp.manage_changeProperties(showAllParents=True)
00091         view = self.view_class(self.portal.folder2.doc21, self.request)
00092         tree = view.navigationTree()
00093         self.failUnless(tree)
00094         found = False
00095         for c in tree['children']:
00096             if c['item'].getPath() == '/plone/folder2':
00097                 found = True
00098                 break
00099         self.failUnless(found)

Definition at line 321 of file testNavigationView.py.

00321 
00322     def testStateFiltering(self):
00323         # Test Navtree workflow state filtering
00324         self.portal._delObject('Members')
00325         self.portal._delObject('news')
00326         self.portal._delObject('events')
00327         workflow = self.portal.portal_workflow
00328         ntp=self.portal.portal_properties.navtree_properties
00329         ntp.manage_changeProperties(wf_states_to_show=['published'])
00330         ntp.manage_changeProperties(enable_wf_state_filtering=True)
00331         view = self.view_class(self.portal.folder2, self.request)
00332         tree = view.navigationTree()
00333         self.failUnless(tree)
00334         self.failUnless(tree.has_key('children'))
00335         #Should only contain current object
00336         self.assertEqual(len(tree['children']), 1)
00337         #change workflow for folder1
00338         workflow.doActionFor(self.portal.folder1, 'publish')
00339         self.portal.folder1.reindexObject()
00340         view = self.view_class(self.portal.folder2, self.request)
00341         tree = view.navigationTree()
00342         #Should only contain current object and published folder
00343         self.assertEqual(len(tree['children']), 2)
00344 
00345     

Definition at line 171 of file testNavigationView.py.

00171 
00172     def testTopLevel(self):
00173         ntp=self.portal.portal_properties.navtree_properties
00174         ntp.manage_changeProperties(topLevel=1)
00175         view = self.view_class(self.portal.folder2.file21, self.request)
00176         tree = view.navigationTree()
00177         self.failUnless(tree)
00178         self.assertEqual(tree['children'][-1]['item'].getPath(), '/plone/folder2/file21')

Definition at line 187 of file testNavigationView.py.

00187 
00188     def testTopLevelTooDeep(self):
00189         ntp=self.portal.portal_properties.navtree_properties
00190         ntp.manage_changeProperties(topLevel=5)
00191         view = self.view_class(self.portal, self.request)
00192         tree = view.navigationTree()
00193         self.failUnless(tree)
00194         self.assertEqual(len(tree['children']), 0)

Here is the call graph for this function:

Definition at line 179 of file testNavigationView.py.

00179 
00180     def testTopLevelWithContextAboveLevel(self):
00181         ntp=self.portal.portal_properties.navtree_properties
00182         ntp.manage_changeProperties(topLevel=1)
00183         view = self.view_class(self.portal, self.request)
00184         tree = view.navigationTree()
00185         self.failUnless(tree)
00186         self.assertEqual(len(tree['children']), 0)

Here is the call graph for this function:

Definition at line 195 of file testNavigationView.py.

00195 
00196     def testTopLevelWithNavigationRoot(self):
00197         self.portal.folder2.invokeFactory('Folder', 'folder21')
00198         self.portal.folder2.folder21.invokeFactory('Document', 'doc211')
00199         ntp=self.portal.portal_properties.navtree_properties
00200         ntp.manage_changeProperties(topLevel=1, root='/folder2')
00201         view = self.view_class(self.portal.folder2.folder21, self.request)
00202         tree = view.navigationTree()
00203         self.failUnless(tree)
00204         self.assertEqual(len(tree['children']), 1)
00205         self.assertEqual(tree['children'][0]['item'].getPath(), '/plone/folder2/folder21/doc211')

Definition at line 206 of file testNavigationView.py.

00206 
00207     def testTopLevelWithPortalFactory(self):
00208         ntp=self.portal.portal_properties.navtree_properties
00209         ntp.manage_changeProperties(topLevel=1)
00210         id=self.portal.generateUniqueId('Document')
00211         typeName='Document'
00212         newObject=self.portal.folder1.restrictedTraverse('portal_factory/' + typeName + '/' + id)
00213         # Will raise a KeyError unless bug is fixed
00214         view = self.view_class(newObject, self.request)
00215         tree = view.navigationTree()
    

Member Data Documentation

Definition at line 29 of file testNavigationView.py.

Reimplemented from CMFPlone.tests.testNavigationView.TestBaseNavTree.

Definition at line 347 of file testNavigationView.py.


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