Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def fail_tb
def testAddAction
def testListFilteredActionsFor
def testPortalTypesIsActionProvider
def testMissingActionProvider
def testBrokenActionProvider
def testMissingListActions
def testDocumentActionsPermissionBug
def testActionNamespace
def testAllActionsAreRenderedAsMessages
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 actions

Detailed Description

Definition at line 25 of file testActionsTool.py.


Member Function Documentation

Definition at line 27 of file testActionsTool.py.

00027 
00028     def afterSetUp(self):
00029         self.actions = self.portal.portal_actions
00030         self.portal.acl_users._doAddUser('user1', 'secret', ['Member'], [])

special fail for capturing errors 

Definition at line 31 of file testActionsTool.py.

00031 
00032     def fail_tb(self, msg):
00033         """ special fail for capturing errors """
00034         import sys
00035         e, v, tb = sys.exc_info()
00036         tb = ''.join(format_exception(e, v, tb))
00037         self.fail("%s\n%s\n" % (msg, tb))

Here is the call graph for this function:

Here is the caller graph for this function:

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:

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 105 of file testActionsTool.py.

00105 
00106     def testActionNamespace(self):
00107         self.actions.addAction(id='foo',
00108                                name='foo_name',
00109                                action='string:${globals_view/isStructuralFolder}',
00110                                condition='',
00111                                permission='View',
00112                                category='folder',
00113                                visible=1)
00114 
00115         actions = self.actions.listFilteredActionsFor(self.folder)
00116         url = actions['folder'][0]['url']

Here is the call graph for this function:

Definition at line 38 of file testActionsTool.py.

00038 
00039     def testAddAction(self):
00040         # addAction should work even though PloneTestCase patches _cloneActions
00041         action_infos = self.actions.listActions()
00042         length = len(action_infos)
00043         self.actions.addAction(id='foo',
00044                                name='foo_name',
00045                                action='foo_action',
00046                                condition='foo_condition',
00047                                permission='foo_permission',
00048                                category='foo_category',
00049                                visible=1)
00050         action_infos = self.actions.listActions()
00051         self.assertEqual(len(action_infos), length + 1)
00052         foo_action = self.actions.getActionObject('foo_category/foo')
00053         self.assertEqual(foo_action.id, 'foo')
00054         self.assertEqual(foo_action.title, 'foo_name')
00055         self.assertEqual(foo_action.permissions, ('foo_permission',))
00056         self.assertEqual(foo_action.category, 'foo_category')

Definition at line 117 of file testActionsTool.py.

00117 
00118     def testAllActionsAreRenderedAsMessages(self):
00119         actions = self.actions.listActions()
00120         for action in actions:
00121             info = ActionInfo(action, self.portal)
00122             self.failUnless(isinstance(info['title'], Message))
00123             self.failUnless(isinstance(info['description'], Message))
00124 

Here is the call graph for this function:

Definition at line 71 of file testActionsTool.py.

00071 
00072     def testBrokenActionProvider(self):
00073         self.portal.portal_types = None
00074         try:
00075             self.actions.listFilteredActionsFor(self.portal)
00076         except:
00077             self.fail_tb('Should not bomb out if a provider is broken')

Here is the call graph for this function:

Definition at line 85 of file testActionsTool.py.

00085 
00086     def testDocumentActionsPermissionBug(self):
00087         # Test to ensure that permissions for items categorized as
00088         # 'document_actions' have their permissions evaluated in the context
00089         # of the content object.
00090         self.actions.addAction(id='foo',
00091                                name='foo_name',
00092                                action='foo_action',
00093                                condition='',
00094                                permission='View',
00095                                category='document_actions',
00096                                visible=1)
00097         actions = self.actions.listFilteredActionsFor(self.folder)
00098         match = [a for a in actions['document_actions'] if a['id'] == 'foo']
00099         self.failUnless(match)
00100         self.portal.portal_workflow.doActionFor(self.folder, 'hide')
00101         self.login('user1')
00102         actions = self.actions.listFilteredActionsFor(self.folder)
00103         match = [a for a in actions.get('document_actions', []) if a['id'] == 'foo']
00104         self.failIf(match)

Here is the call graph for this function:

Definition at line 57 of file testActionsTool.py.

00057 
00058     def testListFilteredActionsFor(self):
00059         self.assertEqual(Set(self.actions.listFilteredActionsFor(self.folder).keys()),
00060                          expected_filtered_actions)

Here is the call graph for this function:

Definition at line 64 of file testActionsTool.py.

00064 
00065     def testMissingActionProvider(self):
00066         self.portal._delObject('portal_types')
00067         try:
00068             self.actions.listFilteredActionsFor(self.portal)
00069         except:
00070             self.fail_tb('Should not bomb out if a provider is missing')

Here is the call graph for this function:

Definition at line 78 of file testActionsTool.py.

00078 
00079     def testMissingListActions(self):
00080         self.portal.portal_types = ExplicitItem()
00081         try:
00082             self.actions.listFilteredActionsFor(self.portal)
00083         except:
00084             self.fail_tb('Should not bomb out if a provider is broken')

Here is the call graph for this function:

Definition at line 61 of file testActionsTool.py.

00061 
00062     def testPortalTypesIsActionProvider(self):
00063         self.failUnless('portal_types' in self.actions.listActionProviders())


Member Data Documentation

Definition at line 28 of file testActionsTool.py.


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