Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testMenuImplementsIBrowserMenu
def testMenuImplementsIFactoriesMenu
def testMenuIncludesFactories
def testTypeNameIsURLQuoted
def testMenuIncludesFactoriesOnNonFolderishContext
def testNoAddableTypes
def testConstrainTypes
def testSettingsIncluded
def testSettingsNotIncludedWhereNotSupported
def testMoreIncluded
def testMoreNotIncludedWhenNotNecessary
def testNonStructualFolderShowsParent

Public Attributes

 menu
 request

Detailed Description

Definition at line 185 of file tests.py.


Member Function Documentation

Definition at line 187 of file tests.py.

00187 
00188     def afterSetUp(self):
00189         self.folder.invokeFactory('Document', 'doc1')
00190         self.menu = getUtility(IBrowserMenu, name='plone_contentmenu_factory', context=self.folder)
00191         self.request = self.app.REQUEST

Definition at line 230 of file tests.py.

00230 
00231     def testConstrainTypes(self):
00232         constraints = ISelectableConstrainTypes(self.folder)
00233         constraints.setConstrainTypesMode(1)
00234         constraints.setLocallyAllowedTypes(('Document',))
00235         constraints.setImmediatelyAddableTypes(('Document',))
00236         actions = self.menu.getMenuItems(self.folder, self.request)
00237         self.assertEqual(len(actions), 2)
00238         self.assertEqual(actions[0]['extra']['id'], 'document')
00239         self.assertEqual(actions[1]['extra']['id'], 'settings')

Here is the call graph for this function:

Definition at line 192 of file tests.py.

00192 
00193     def testMenuImplementsIBrowserMenu(self):
00194         self.failUnless(IBrowserMenu.providedBy(self.menu))

Definition at line 195 of file tests.py.

00195 
00196     def testMenuImplementsIFactoriesMenu(self):
00197         self.failUnless(IFactoriesMenu.providedBy(self.menu))

Definition at line 198 of file tests.py.

00198 
00199     def testMenuIncludesFactories(self):
00200         actions = self.menu.getMenuItems(self.folder, self.request)
00201         self.failUnless('image' in [a['extra']['id'] for a in actions])

Here is the call graph for this function:

Definition at line 206 of file tests.py.

00206 
00207     def testMenuIncludesFactoriesOnNonFolderishContext(self):
00208         actions = self.menu.getMenuItems(self.folder.doc1, self.request)
00209         img = None
00210         for a in actions:
00211             if a['extra']['id'] == 'image':
00212                 img = a
00213                 break
00214         self.failIf(img is None)
00215         action = img['action']
00216         url = self.folder.absolute_url()
00217         self.failUnless(action.startswith(url))
00218         url = self.folder.doc1.absolute_url()
00219         self.failIf(action.startswith(url))

Definition at line 249 of file tests.py.

00249 
00250     def testMoreIncluded(self):
00251         constraints = ISelectableConstrainTypes(self.folder)
00252         constraints.setConstrainTypesMode(1)
00253         constraints.setLocallyAllowedTypes(('Document', 'Image',))
00254         constraints.setImmediatelyAddableTypes(('Document',))
00255         actions = self.menu.getMenuItems(self.folder, self.request)
00256         self.failIf('image' in [a['extra']['id'] for a in actions])
00257         self.failUnless('document' in [a['extra']['id'] for a in actions])
00258         self.failUnless('more' in [a['extra']['id'] for a in actions])
00259         self.failUnless('settings' in [a['extra']['id'] for a in actions])

Here is the call graph for this function:

Definition at line 260 of file tests.py.

00260 
00261     def testMoreNotIncludedWhenNotNecessary(self):
00262         constraints = ISelectableConstrainTypes(self.folder)
00263         constraints.setConstrainTypesMode(1)
00264         constraints.setLocallyAllowedTypes(('Document',))
00265         constraints.setImmediatelyAddableTypes(('Document',))
00266         actions = self.menu.getMenuItems(self.folder, self.request)
00267         self.assertEqual(len(actions), 2)
00268         self.assertEqual(actions[0]['extra']['id'], 'document')
00269         self.assertEqual(actions[1]['extra']['id'], 'settings')

Here is the call graph for this function:

Definition at line 220 of file tests.py.

00220 
00221     def testNoAddableTypes(self):
00222         actions = self.menu.getMenuItems(self.portal, self.request)
00223         self.assertEqual(len(actions), 0)
00224         
00225         # set no types for folders and check the menu is not shown
00226         folder_fti = self.portal.portal_types['Folder']
00227         folder_fti.manage_changeProperties(filter_content_types=True, allowed_content_types=[])
00228         actions = self.menu.getMenuItems(self.folder, self.request)
00229         self.assertEqual(len(actions), 0)

Here is the call graph for this function:

Definition at line 270 of file tests.py.

00270 
00271     def testNonStructualFolderShowsParent(self):
00272         # Cope with an unfortunate side-effect of running all plone.* tests at
00273         # once. Some tests setup the Archetypes examples types and don't use
00274         # their own layer for it :(
00275         for t in ('ATBIFolder', 'ComplexType', 'DDocument'):
00276             if t in self.portal.portal_types.keys():
00277                 self.portal.portal_types[t].global_allow = False
00278 
00279         self.folder.invokeFactory('Folder', 'folder1')
00280         directlyProvides(self.folder.folder1, INonStructuralFolder)
00281         constraints = ISelectableConstrainTypes(self.folder.folder1)
00282         constraints.setConstrainTypesMode(1)
00283         constraints.setLocallyAllowedTypes(('Document',))
00284         constraints.setImmediatelyAddableTypes(('Document',))
00285         actions = self.menu.getMenuItems(self.folder.folder1, self.request)
00286         self.failUnless('event' in actions[0]['extra']['id'])
00287 

Here is the call graph for this function:

Definition at line 240 of file tests.py.

00240 
00241     def testSettingsIncluded(self):
00242         actions = self.menu.getMenuItems(self.folder, self.request)
00243         self.assertEqual(actions[-1]['extra']['id'], 'settings')

Here is the call graph for this function:

Definition at line 244 of file tests.py.

00244 
00245     def testSettingsNotIncludedWhereNotSupported(self):
00246         self.folder.manage_permission('Modify constrain types', ('Manager',))
00247         actions = self.menu.getMenuItems(self.folder, self.request)
00248         self.failIf('_settings' in [a['extra']['id'] for a in actions])

Here is the call graph for this function:

Definition at line 202 of file tests.py.

00202 
00203     def testTypeNameIsURLQuoted(self):
00204         actions = self.menu.getMenuItems(self.folder, self.request)
00205         self.failUnless(self.folder.absolute_url() + '/createObject?type_name=News+Item' in [a['action'] for a in actions])

Here is the call graph for this function:


Member Data Documentation

Definition at line 189 of file tests.py.

Definition at line 190 of file tests.py.


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