[CMF-checkins] CVS: Products/CMFCore/tests -
test_ActionInformation.py:1.12
test_ActionProviderBase.py:1.18 test_ActionsTool.py:1.18
Yvo Schubbe
y.2005- at wcm-solutions.de
Tue Jan 25 14:50:12 EST 2005
Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv24836/CMFCore/tests
Modified Files:
test_ActionInformation.py test_ActionProviderBase.py
test_ActionsTool.py
Log Message:
merged yuppie-new_actions-branch:
- added ActionCategory and Action interfaces
- added ActionCategory and Action classes
- modified ActionsTool to make use of these new classes
- removed deprecated 'name' and 'permissions' keys from ActionInfo
- allowed 'description' key in ActionInfo
- implemented IAction in the oldstyle ActionInformation class and used this interface to simplify ActionInfo
- updated setup handlers, tests, default profile and skins
- fixed ActionInfo issue regarding permissions in oldstyle action dicts
=== Products/CMFCore/tests/test_ActionInformation.py 1.11 => 1.12 ===
--- Products/CMFCore/tests/test_ActionInformation.py:1.11 Fri Sep 3 13:14:01 2004
+++ Products/CMFCore/tests/test_ActionInformation.py Tue Jan 25 14:49:41 2005
@@ -9,10 +9,76 @@
from Products.CMFCore.Expression import createExprContext
from Products.CMFCore.Expression import Expression
from Products.CMFCore.tests.base.dummy import DummyContent
+from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool as DummyMembershipTool
+from Products.CMFCore.tests.base.testcase import SecurityTest
from Products.CMFCore.tests.base.testcase import TransactionalTest
+class ActionCategoryTests(TestCase):
+
+ def _makeOne(self, *args, **kw):
+ from Products.CMFCore.ActionInformation import ActionCategory
+
+ return ActionCategory(*args, **kw)
+
+ def test_interface(self):
+ from Products.CMFCore.interfaces.portal_actions \
+ import ActionCategory as IActionCategory
+ from Products.CMFCore.ActionInformation import ActionCategory
+
+ verifyClass(IActionCategory, ActionCategory)
+
+ def test_listActions(self):
+ from Products.CMFCore.ActionInformation import Action
+
+ ac = self._makeOne('foo')
+ self.assertEqual( ac.listActions(), () )
+
+ baz = Action('baz')
+ ac._setObject('baz', baz)
+ self.assertEqual( ac.listActions(), (baz,) )
+
+
+class ActionTests(TestCase):
+
+ def _makeOne(self, *args, **kw):
+ from Products.CMFCore.ActionInformation import Action
+
+ return Action(*args, **kw)
+
+ def test_interface(self):
+ from Products.CMFCore.interfaces.portal_actions \
+ import Action as IAction
+ from Products.CMFCore.ActionInformation import Action
+
+ verifyClass(IAction, Action)
+
+ def test_getInfoData_empty(self):
+ WANTED = ( {'available': True, 'category': '', 'description': '',
+ 'id': 'foo', 'icon': '', 'permissions': (), 'title': '',
+ 'url': '', 'visible': True}, [] )
+ a = self._makeOne('foo')
+ self.assertEqual( a.getInfoData(), WANTED )
+
+ def test_getInfoData_normal(self):
+ a = self._makeOne('foo',
+ title='Foo Title',
+ description='Foo description.',
+ url_expr='string:${object_url}/foo_url',
+ icon_expr='string:foo_icon',
+ available_expr='',
+ permissions=('View',),
+ visible=False)
+ WANTED = ( {'available': True, 'category': '',
+ 'description': 'Foo description.',
+ 'id': 'foo', 'icon': a.icon_expr_object,
+ 'permissions': ('View',), 'title': 'Foo Title',
+ 'url': a.url_expr_object, 'visible': False},
+ ['url', 'icon'] )
+ self.assertEqual( a.getInfoData(), WANTED )
+
+
class ActionInfoTests(TestCase):
def _makeOne(self, *args, **kw):
@@ -27,45 +93,94 @@
verifyClass(IActionInfo, ActionInfo)
+ def test_create_from_Action(self):
+ from Products.CMFCore.ActionInformation import Action
+
+ WANTED = {'allowed': True, 'available': True, 'category': '',
+ 'description': '', 'icon': '', 'id': 'foo', 'title': '',
+ 'url': '', 'visible': True}
+
+ action = Action(id='foo')
+ ec = None
+ ai = self._makeOne(action, ec)
+
+ self.assertEqual( ai['id'], WANTED['id'] )
+ self.assertEqual( ai['title'], WANTED['title'] )
+ self.assertEqual( ai['description'], WANTED['description'] )
+ self.assertEqual( ai['url'], WANTED['url'] )
+ self.assertEqual( ai['category'], WANTED['category'] )
+ self.assertEqual( ai['visible'], WANTED['visible'] )
+ self.assertEqual( ai['available'], WANTED['available'] )
+ self.assertEqual( ai['allowed'], WANTED['allowed'] )
+ self.assertEqual( ai, WANTED )
+
def test_create_from_ActionInformation(self):
from Products.CMFCore.ActionInformation import ActionInformation
- wanted = {'allowed': True, 'available': True, 'category': 'object',
- 'id': 'foo', 'name': 'foo', 'permissions': (),
- 'title': 'foo', 'url': '', 'visible': True}
+ WANTED = {'allowed': True, 'available': True, 'category': 'object',
+ 'description': '', 'id': 'foo', 'title': 'foo', 'url': '',
+ 'visible': True}
action = ActionInformation(id='foo')
ec = None
ai = self._makeOne(action, ec)
- self.assertEqual( ai['id'], wanted['id'] )
- self.assertEqual( ai['title'], wanted['title'] )
- self.assertEqual( ai['url'], wanted['url'] )
- self.assertEqual( ai['permissions'], wanted['permissions'] )
- self.assertEqual( ai['category'], wanted['category'] )
- self.assertEqual( ai['visible'], wanted['visible'] )
- self.assertEqual( ai['available'], wanted['available'] )
- self.assertEqual( ai['allowed'], wanted['allowed'] )
- self.assertEqual( ai, wanted )
+ self.assertEqual( ai['id'], WANTED['id'] )
+ self.assertEqual( ai['title'], WANTED['title'] )
+ self.assertEqual( ai['description'], WANTED['description'] )
+ self.assertEqual( ai['url'], WANTED['url'] )
+ self.assertEqual( ai['category'], WANTED['category'] )
+ self.assertEqual( ai['visible'], WANTED['visible'] )
+ self.assertEqual( ai['available'], WANTED['available'] )
+ self.assertEqual( ai['allowed'], WANTED['allowed'] )
+ self.assertEqual( ai, WANTED )
def test_create_from_dict(self):
- wanted = {'allowed': True, 'available': True, 'category': 'object',
- 'id': 'foo', 'name': 'foo', 'permissions': (),
- 'title': 'foo', 'url': '', 'visible': True}
+ WANTED = {'allowed': True, 'available': True, 'category': 'object',
+ 'id': 'foo', 'title': 'foo', 'url': '', 'visible': True}
action = {'name': 'foo', 'url': ''}
ec = None
ai = self._makeOne(action, ec)
- self.assertEqual( ai['id'], wanted['id'] )
- self.assertEqual( ai['title'], wanted['title'] )
- self.assertEqual( ai['url'], wanted['url'] )
- self.assertEqual( ai['permissions'], wanted['permissions'] )
- self.assertEqual( ai['category'], wanted['category'] )
- self.assertEqual( ai['visible'], wanted['visible'] )
- self.assertEqual( ai['available'], wanted['available'] )
- self.assertEqual( ai['allowed'], wanted['allowed'] )
- self.assertEqual( ai, wanted )
+ self.assertEqual( ai['id'], WANTED['id'] )
+ self.assertEqual( ai['title'], WANTED['title'] )
+ self.assertEqual( ai['url'], WANTED['url'] )
+ self.assertEqual( ai['category'], WANTED['category'] )
+ self.assertEqual( ai['visible'], WANTED['visible'] )
+ self.assertEqual( ai['available'], WANTED['available'] )
+ self.assertEqual( ai['allowed'], WANTED['allowed'] )
+ self.assertEqual( ai, WANTED )
+
+
+class ActionInfoSecurityTests(SecurityTest):
+
+ def setUp(self):
+ SecurityTest.setUp(self)
+ self.site = DummySite('site').__of__(self.root)
+ self.site._setObject( 'portal_membership', DummyMembershipTool() )
+
+ def _makeOne(self, *args, **kw):
+ from Products.CMFCore.ActionInformation import ActionInfo
+
+ return ActionInfo(*args, **kw)
+
+ def test_create_from_dict(self):
+ WANTED = {'allowed': True, 'available': True, 'category': 'object',
+ 'id': 'foo', 'title': 'foo', 'url': '', 'visible': True}
+
+ action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
+ ec = createExprContext(self.site, self.site, None)
+ ai = self._makeOne(action, ec)
+
+ self.assertEqual( ai['id'], WANTED['id'] )
+ self.assertEqual( ai['title'], WANTED['title'] )
+ self.assertEqual( ai['url'], WANTED['url'] )
+ self.assertEqual( ai['category'], WANTED['category'] )
+ self.assertEqual( ai['visible'], WANTED['visible'] )
+ self.assertEqual( ai['available'], WANTED['available'] )
+ self.assertEqual( ai['allowed'], WANTED['allowed'] )
+ self.assertEqual( ai, WANTED )
class ActionInformationTests(TransactionalTest):
@@ -86,6 +201,13 @@
return ActionInformation(*args, **kw)
+ def test_interface(self):
+ from Products.CMFCore.interfaces.portal_actions \
+ import Action as IAction
+ from Products.CMFCore.ActionInformation import ActionInformation
+
+ verifyClass(IAction, ActionInformation)
+
def test_basic_construction(self):
ai = self._makeOne(id='view')
@@ -159,11 +281,35 @@
self.failUnless(ai.testCondition(ec))
+ def test_getInfoData_empty(self):
+ WANTED = ( {'available': True, 'category': 'object',
+ 'description': '', 'id': 'foo', 'permissions': (),
+ 'title': 'foo', 'url': '', 'visible': True}, [] )
+ a = self._makeOne('foo')
+ self.assertEqual( a.getInfoData(), WANTED )
+
+ def test_getInfoData_normal(self):
+ a = self._makeOne('foo',
+ title='Foo Title',
+ description='Foo description.',
+ action='string:${object_url}/foo_url',
+ condition='',
+ permissions=('View',),
+ visible=False)
+ WANTED = ( {'available': True, 'category': 'object',
+ 'description': 'Foo description.', 'id': 'foo',
+ 'permissions': ('View',), 'title': 'Foo Title',
+ 'url': a._getActionObject(), 'visible': False},
+ ['url'] )
+ self.assertEqual( a.getInfoData(), WANTED )
def test_suite():
return TestSuite((
+ makeSuite(ActionCategoryTests),
+ makeSuite(ActionTests),
makeSuite(ActionInfoTests),
+ makeSuite(ActionInfoSecurityTests),
makeSuite(ActionInformationTests),
))
=== Products/CMFCore/tests/test_ActionProviderBase.py 1.17 => 1.18 ===
--- Products/CMFCore/tests/test_ActionProviderBase.py:1.17 Mon Jul 26 06:13:14 2004
+++ Products/CMFCore/tests/test_ActionProviderBase.py Tue Jan 25 14:49:41 2005
@@ -211,9 +211,9 @@
self.assertEqual( old_ids, another_ids )
def test_listActionInfos(self):
- wanted = [{'id': 'an_id', 'title': 'A Title', 'name': 'A Title',
- 'url': '', 'permissions': (), 'category': 'object',
- 'visible': False, 'available': True, 'allowed': True}]
+ wanted = [{'id': 'an_id', 'title': 'A Title', 'description': '',
+ 'url': '', 'category': 'object', 'visible': False,
+ 'available': True, 'allowed': True}]
apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
rval = apb.listActionInfos()
@@ -232,9 +232,9 @@
self.assertRaises(ValueError, apb.getActionObject, 'wrong_format')
def test_getActionInfo(self):
- wanted = {'id': 'an_id', 'title': 'A Title', 'name': 'A Title',
- 'url': '', 'permissions': (), 'category': 'object',
- 'visible': False, 'available': True, 'allowed': True}
+ wanted = {'id': 'an_id', 'title': 'A Title', 'description': '',
+ 'url': '', 'category': 'object', 'visible': False,
+ 'available': True, 'allowed': True}
apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
rval = apb.getActionInfo( ('object/an_id',) )
=== Products/CMFCore/tests/test_ActionsTool.py 1.17 => 1.18 ===
--- Products/CMFCore/tests/test_ActionsTool.py:1.17 Mon Jul 26 06:13:14 2004
+++ Products/CMFCore/tests/test_ActionsTool.py Tue Jan 25 14:49:41 2005
@@ -4,11 +4,8 @@
Zope.startup()
from Interface.Verify import verifyClass
-from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.ActionsTool import ActionsTool
-from Products.CMFCore.Expression import Expression
from Products.CMFCore.MembershipTool import MembershipTool
-from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFCore.RegistrationTool import RegistrationTool
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
from Products.CMFCore.TypesTool import TypesTool
@@ -63,11 +60,10 @@
{'workflow': [],
'user': [],
'object': [],
- 'folder': [{'permissions': ('List folder contents',),
- 'id': 'folderContents',
+ 'folder': [{'id': 'folderContents',
'url': 'http://foo/folder_contents',
'title': 'Folder contents',
- 'name': 'Folder contents',
+ 'description': '',
'visible': True,
'available': True,
'allowed': True,
More information about the CMF-checkins
mailing list