[CMF-checkins] CVS: Products/CMFCore/tests -
test_ActionInformation.py:1.11.6.1
Yvo Schubbe
y.2005- at wcm-solutions.de
Mon Jan 24 14:31:46 EST 2005
Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv30226/CMFCore/tests
Modified Files:
Tag: yuppie-new_actions-branch
test_ActionInformation.py
Log Message:
- initial checkin of newstyle Actions
=== Products/CMFCore/tests/test_ActionInformation.py 1.11 => 1.11.6.1 ===
--- Products/CMFCore/tests/test_ActionInformation.py:1.11 Fri Sep 3 13:14:01 2004
+++ Products/CMFCore/tests/test_ActionInformation.py Mon Jan 24 14:31:15 2005
@@ -13,6 +13,70 @@
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 +91,66 @@
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',
+ 'permissions': (), '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['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 )
+
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',
+ 'id': 'foo', 'name': 'foo', 'permissions': (),
+ '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['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 )
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', 'name': 'foo', 'permissions': (),
+ '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['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 )
class ActionInformationTests(TransactionalTest):
@@ -163,6 +248,8 @@
def test_suite():
return TestSuite((
+ makeSuite(ActionCategoryTests),
+ makeSuite(ActionTests),
makeSuite(ActionInfoTests),
makeSuite(ActionInformationTests),
))
More information about the CMF-checkins
mailing list