[CMF-checkins] CVS: CMF/CMFCore/tests - test_ActionsTool.py:1.5
Chris Withers
chrisw@nipltd.com
Sat, 9 Mar 2002 12:23:43 -0500
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv7103/CMFCore/tests
Modified Files:
test_ActionsTool.py
Log Message:
Fixed ActionsTool so that duplicate actions are stripped
=== CMF/CMFCore/tests/test_ActionsTool.py 1.4 => 1.5 ===
from Products.CMFCore.TypesTool import TypesTool
from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFCore.ActionInformation import ActionInformation
+from Products.CMFCore.Expression import Expression
from Products.CMFDefault.URLTool import URLTool
from Products.CMFDefault.RegistrationTool import RegistrationTool
from Products.CMFDefault.MembershipTool import MembershipTool
@@ -20,6 +22,8 @@
root = self.root
root._setObject( 'portal_actions', ActionsTool() )
root._setObject('foo', URLTool() )
+ root._setObject('portal_membership', MembershipTool())
+ root._setObject('portal_types', TypesTool())
self.tool = root.portal_actions
self.ut = root.foo
self.tool.action_providers = ('portal_actions',)
@@ -48,8 +52,6 @@
root = self.root
tool = self.tool
root._setObject('portal_registration', RegistrationTool())
- root._setObject('portal_membership', MembershipTool())
- root._setObject('portal_types', TypesTool())
self.tool.action_providers = ('portal_actions','portal_registration')
self.assertEqual(tool.listFilteredActionsFor(root.portal_registration),
{'workflow': [],
@@ -71,8 +73,6 @@
root = self.root
tool = self.tool
root._setObject('donkey', PortalFolder('donkey'))
- root._setObject('portal_membership', MembershipTool())
- root._setObject('portal_types', TypesTool())
self.assertEqual(tool.listFilteredActionsFor(root.donkey),
{'workflow': [],
'user': [],
@@ -84,6 +84,33 @@
'visible': 1,
'category': 'folder'}],
'global': []})
+
+ def test_DuplicateActions(self):
+ """
+ Check that listFilteredActionsFor
+ filters out duplicate actions.
+ """
+ root = self.root
+ tool = self.tool
+ action = ActionInformation(id='test',
+ title='Test',
+ action=Expression(
+ text='string: a_url'
+ ),
+ condition='',
+ permissions=(),
+ category='object',
+ visible=1
+ )
+ tool._actions = [action,action]
+ self.tool.action_providers = ('portal_actions',)
+ self.assertEqual(tool.listFilteredActionsFor(root)['object'],
+ [{'permissions': (),
+ 'id': 'test',
+ 'url': ' a_url',
+ 'name': 'Test',
+ 'visible': 1,
+ 'category': 'object'}])
def test_suite():
return TestSuite((