Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.app.contentmenu.tests.TestContentMenu Class Reference

List of all members.

Public Member Functions

def afterSetUp
def testActionsSubMenuIncluded
def testDisplayMenuIncluded
def testDisplayMenuNotIncludedIfContextDoesNotSupportBrowserDefault
def testDisplayMenuShowFolderDefaultPageWhenContextDoesNotSupportSelectableBrowserDefault
def testDisplayMenuNotIncludedIfNoActionsAvailable
def testDisplayMenuDisabledIfIndexHtmlInFolder
def testDisplayMenuDisabledIfIndexHtmlInFolderAndContextIsIndexHtml
def testAddMenuIncluded
def testAddMenuNotIncludedIfNothingToAdd
def testAddMenuWithNothingToAddButWithAvailableConstrainSettings
def testAddMenuWithNothingToAddButWithAvailableMorePage
def testAddMenuRelativeToNonStructuralFolder
def testAddMenuWithSingleItemCollapses
def testWorkflowMenuIncluded
def testWorkflowMenuWithNoTransitionsDisabled
def DISABLED_testWorkflowMenuWithNoTransitionsEnabledAsManager
def testWorkflowMenuWithNoWorkflowNotIncluded

Public Attributes

 menu
 request

Detailed Description

Definition at line 349 of file tests.py.


Member Function Documentation

Definition at line 351 of file tests.py.

00351 
00352     def afterSetUp(self):
00353         self.menu = getUtility(IBrowserMenu, name='plone_contentmenu', context=self.folder)
00354         self.request = self.app.REQUEST

Definition at line 471 of file tests.py.

00471 
00472     def DISABLED_testWorkflowMenuWithNoTransitionsEnabledAsManager(self):
00473         # set workflow guard condition that fails, so there are no transitions.
00474         # then show that manager will get a drop-down with settings whilst
00475         # regular users won't
00476 
00477         self.portal.portal_workflow.doActionFor(self.folder, 'hide')
00478         wf = self.portal.portal_workflow['folder_workflow']
00479         wf.transitions['show'].guard.expr = Expression('python: False')
00480         wf.transitions['publish'].guard.expr = Expression('python: False')
00481 
00482         items = self.menu.getMenuItems(self.folder, self.request)
00483         workflowMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-workflow'][0]
00484 
00485         # A regular user doesn't see any actions
00486         self.failUnless(workflowMenuItem['action'] == '')
00487         self.failUnless(workflowMenuItem['submenu'] is None)
00488 
00489         self.fail('Unable to write a proper test so far')

Here is the call graph for this function:

Definition at line 357 of file tests.py.

00357 
00358     def testActionsSubMenuIncluded(self):
00359         items = self.menu.getMenuItems(self.folder, self.request)
00360         actionsMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-actions'][0]
00361         self.assertEqual(actionsMenuItem['action'], self.folder.absolute_url() + '/folder_contents')
00362         self.failUnless(len(actionsMenuItem['submenu']) > 0)

Here is the call graph for this function:

Definition at line 406 of file tests.py.

00406 
00407     def testAddMenuIncluded(self):
00408         items = self.menu.getMenuItems(self.folder, self.request)
00409         factoriesMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-factories'][0]
00410         self.assertEqual(factoriesMenuItem['action'], self.folder.absolute_url() + '/folder_factories')
00411         self.failUnless(len(factoriesMenuItem['submenu']) > 0)
00412         self.assertEqual(factoriesMenuItem['extra']['hideChildren'], False)

Here is the call graph for this function:

Definition at line 413 of file tests.py.

00413 
00414     def testAddMenuNotIncludedIfNothingToAdd(self):
00415         self.logout()
00416         items = self.menu.getMenuItems(self.folder, self.request)
00417         self.assertEqual([i for i in items if i['extra']['id'] == 'plone-contentmenu-factories'], [])

Here is the call graph for this function:

Definition at line 437 of file tests.py.

00437 
00438     def testAddMenuRelativeToNonStructuralFolder(self):
00439         self.folder.invokeFactory('Folder', 'f1')
00440         directlyProvides(self.folder.f1, INonStructuralFolder)
00441         items = self.menu.getMenuItems(self.folder.f1, self.request)
00442         factoriesMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-factories']
00443         self.failIf(factoriesMenuItem)

Here is the call graph for this function:

Definition at line 418 of file tests.py.

00418 
00419     def testAddMenuWithNothingToAddButWithAvailableConstrainSettings(self):
00420         self.folder.setConstrainTypesMode(1)
00421         self.folder.setLocallyAllowedTypes(())
00422         self.folder.setImmediatelyAddableTypes(())
00423         items = self.menu.getMenuItems(self.folder, self.request)
00424         factoriesMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-factories'][0]
00425         self.assertEqual(len(factoriesMenuItem['submenu']), 1)
00426         self.assertEqual(factoriesMenuItem['submenu'][0]['extra']['id'], 'settings')

Here is the call graph for this function:

Definition at line 427 of file tests.py.

00427 
00428     def testAddMenuWithNothingToAddButWithAvailableMorePage(self):
00429         self.folder.setConstrainTypesMode(1)
00430         self.folder.setLocallyAllowedTypes(('Document',))
00431         self.folder.setImmediatelyAddableTypes(())
00432         self.folder.manage_permission('Modify constrain types', ('Manager',))
00433         items = self.menu.getMenuItems(self.folder, self.request)
00434         factoriesMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-factories'][0]
00435         self.assertEqual(len(factoriesMenuItem['submenu']), 1)
00436         self.assertEqual(factoriesMenuItem['submenu'][0]['extra']['id'], 'more')

Here is the call graph for this function:

Definition at line 444 of file tests.py.

00444 
00445     def testAddMenuWithSingleItemCollapses(self):
00446         # we need a dummy to test this - should test that if the item does not
00447         # support constrain types and there is
00448         self.folder.setConstrainTypesMode(1)
00449         self.folder.setLocallyAllowedTypes(('Document',))
00450         self.folder.setImmediatelyAddableTypes(('Document',))
00451         self.folder.manage_permission('Modify constrain types', ('Manager',))
00452         items = self.menu.getMenuItems(self.folder, self.request)
00453         factoriesMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-factories'][0]
00454         self.assertEqual(factoriesMenuItem['action'], self.folder.absolute_url() + '/createObject?type_name=Document')
00455         self.assertEqual(factoriesMenuItem['extra']['hideChildren'], True)

Here is the call graph for this function:

Definition at line 392 of file tests.py.

00392 
00393     def testDisplayMenuDisabledIfIndexHtmlInFolder(self):
00394         self.folder.invokeFactory('Document', 'index_html')
00395         items = self.menu.getMenuItems(self.folder, self.request)
00396         displayMenuItems = [i for i in items if i['extra']['id'] == 'plone-contentmenu-display']
00397         self.assertEqual(len(displayMenuItems), 0)

Here is the call graph for this function:

Definition at line 398 of file tests.py.

00398 
00399     def testDisplayMenuDisabledIfIndexHtmlInFolderAndContextIsIndexHtml(self):
00400         self.folder.invokeFactory('Document', 'index_html')
00401         items = self.menu.getMenuItems(self.folder.index_html, self.request)
00402         displayMenuItems = [i for i in items if i['extra']['id'] == 'plone-contentmenu-display']
00403         self.assertEqual(len(displayMenuItems), 0)

Definition at line 365 of file tests.py.

00365 
00366     def testDisplayMenuIncluded(self):
00367         items = self.menu.getMenuItems(self.folder, self.request)
00368         displayMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-display'][0]
00369         self.assertEqual(displayMenuItem['action'], self.folder.absolute_url() + '/select_default_view')
00370         self.failUnless(len(displayMenuItem['submenu']) > 0)

Here is the call graph for this function:

Definition at line 371 of file tests.py.

00371 
00372     def testDisplayMenuNotIncludedIfContextDoesNotSupportBrowserDefault(self):
00373         # We need to create an object that does not have IBrowserDefault enabled
00374         _createObjectByType('ATListCriterion', self.folder, 'c1')
00375         items = self.menu.getMenuItems(self.folder.c1, self.request)
00376         self.assertEqual([i for i in items if i['extra']['id'] == 'plone-contentmenu-display'], [])

Here is the call graph for this function:

Definition at line 387 of file tests.py.

00387 
00388     def testDisplayMenuNotIncludedIfNoActionsAvailable(self):
00389         self.folder.invokeFactory('Document', 'doc1')
00390         items = self.menu.getMenuItems(self.folder.doc1, self.request)
00391         self.assertEqual([i for i in items if i['extra']['id'] == 'plone-contentmenu-display'], [])

Definition at line 377 of file tests.py.

00377 
00378     def testDisplayMenuShowFolderDefaultPageWhenContextDoesNotSupportSelectableBrowserDefault(self):
00379         # We need to create an object that is not ISelectableBrowserDefault aware
00380         _createObjectByType('ATListCriterion', self.folder, 'c1')
00381         self.folder.c1.setTitle('Foo')
00382         self.folder.setDefaultPage('c1')
00383         items = self.menu.getMenuItems(self.folder.c1, self.request)
00384         displayMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-display'][0]
00385         selected =  [a for a in displayMenuItem['submenu'] if a['selected']][0]
00386         self.assertEqual(u'Foo', selected['title'].mapping['contentitem'])

Here is the call graph for this function:

Definition at line 458 of file tests.py.

00458 
00459     def testWorkflowMenuIncluded(self):
00460         items = self.menu.getMenuItems(self.folder, self.request)
00461         workflowMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-workflow'][0]
00462         self.assertEqual(workflowMenuItem['action'], self.folder.absolute_url() + '/content_status_history')
00463         self.failUnless(len(workflowMenuItem['submenu']) > 0)

Here is the call graph for this function:

Definition at line 464 of file tests.py.

00464 
00465     def testWorkflowMenuWithNoTransitionsDisabled(self):
00466         self.logout()
00467         items = self.menu.getMenuItems(self.folder, self.request)
00468         workflowMenuItem = [i for i in items if i['extra']['id'] == 'plone-contentmenu-workflow'][0]
00469         self.assertEqual(workflowMenuItem['action'], '')

Here is the call graph for this function:

Definition at line 490 of file tests.py.

00490 
00491     def testWorkflowMenuWithNoWorkflowNotIncluded(self):
00492         self.portal.portal_workflow.setChainForPortalTypes(('Document',), ())
00493         self.folder.invokeFactory('Document', 'doc1')
00494         actions = self.menu.getMenuItems(self.folder.doc1, self.request)
00495         self.failIf('plone_contentmenu_workflow' in [a['extra']['id'] for a in actions])
00496 


Member Data Documentation

Definition at line 352 of file tests.py.

Definition at line 353 of file tests.py.


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