[CMF-checkins] CVS: CMF/CMFCore/tests -
test_ActionProviderBase.py:1.8.32.1
Yvo Schubbe
cvs-admin at zope.org
Tue Nov 25 08:59:56 EST 2003
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv31480/CMFCore/tests
Modified Files:
Tag: yuppie-listActionInfos-branch
test_ActionProviderBase.py
Log Message:
refactoring (part 2):
- added listActionInfos() and getActionInfo() to the ActionProvider Interface
- made OldstyleActionProvider Interface inherit these 2 methods
- added 'object' argument to listActions() of the ActionProvider Interface
- implemented new / changed methods in ActionProviderBase and TypesTool
- added OldstyleActionProviderBase implementing OldstyleActionProvider
- WorkflowTool and CMFCore DiscussionTool now use OldstyleActionProviderBase
=== CMF/CMFCore/tests/test_ActionProviderBase.py 1.8 => 1.8.32.1 ===
--- CMF/CMFCore/tests/test_ActionProviderBase.py:1.8 Mon Jan 6 15:40:27 2003
+++ CMF/CMFCore/tests/test_ActionProviderBase.py Tue Nov 25 08:59:56 2003
@@ -1,12 +1,20 @@
-import unittest
+from unittest import TestCase, TestSuite, makeSuite, main
+
import Zope
try:
+ Zope.startup()
+except AttributeError:
+ # for Zope versions before 2.6.1
+ pass
+try:
from Interface.Verify import verifyClass
except ImportError:
# for Zope versions before 2.6.0
from Interface import verify_class_implementation as verifyClass
+from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
+from Products.CMFCore.tests.base.testcase import SecurityRequestTest
#
# We have to import these here to make the "ugly sharing" test case go.
@@ -14,7 +22,8 @@
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.ActionInformation import ActionInformation
-class DummyProvider( ActionProviderBase ):
+
+class DummyProvider(ActionProviderBase, DummyTool):
_actions = ( ActionInformation( id='an_id'
, title='A Title'
@@ -25,6 +34,7 @@
, visible=0
), )
+
class DummyAction:
def __init__( self, value ):
@@ -40,8 +50,15 @@
or 0
)
-class ActionProviderBaseTests(unittest.TestCase):
+
+class ActionProviderBaseTests(SecurityRequestTest):
+ def setUp( self ):
+ SecurityRequestTest.setUp(self)
+ self.site = DummySite('site').__of__(self.root)
+ utool = self.site._setObject( 'portal_url', DummyTool() )
+ mtool = self.site._setObject( 'portal_membership', DummyTool() )
+
def _makeProvider( self, dummy=0 ):
klass = dummy and DummyProvider or ActionProviderBase
@@ -66,7 +83,6 @@
def test_changeActions( self ):
-
apb = DummyTool()
old_actions = list( apb._actions )
@@ -147,16 +163,31 @@
self.failIf( one_ids == another_ids )
self.assertEqual( old_ids, another_ids )
+ def test_listActionInfos(self):
+ apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
+ rval = apb.listActionInfos()
+ self.assertEqual( rval, [] )
+ rval = apb.listActionInfos(check_visibility=0)
+ self.assertEqual( rval, [{'permissions': '', 'id': 'an_id', 'url': '',
+ 'name': 'A Title', 'visible': 0, 'category': 'object'}] )
+
+ def test_getActionInfo(self):
+ apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
+ rval = apb.getActionInfo( ('object/an_id',) )
+ self.assertEqual( rval, {'permissions': '', 'id': 'an_id', 'url': '',
+ 'name': 'A Title', 'visible': 0, 'category': 'object'} )
+
def test_interface(self):
from Products.CMFCore.interfaces.portal_actions \
import ActionProvider as IActionProvider
verifyClass(IActionProvider, ActionProviderBase)
+
def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(ActionProviderBaseTests),
+ return TestSuite((
+ makeSuite(ActionProviderBaseTests),
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ main(defaultTest='test_suite')
More information about the CMF-checkins
mailing list