[CMF-checkins] CVS: CMF/CMFCore/tests - test_ActionsTool.py:1.3.2.1
Chris Withers
chrisw@nipltd.com
Fri, 15 Feb 2002 11:50:52 -0500
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv31928
Modified Files:
Tag: ChrisW-refactor_tests-branch
test_ActionsTool.py
Log Message:
Done ActionsTool
=== CMF/CMFCore/tests/test_ActionsTool.py 1.3 => 1.3.2.1 ===
from unittest import TestCase,TestSuite,makeSuite,main
+
+from Products.CMFCore.tests.base.testcase import \
+ SecurityRequestTest
+
from Products.CMFCore.ActionsTool import ActionsTool
from Products.CMFCore.TypesTool import TypesTool
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFDefault.URLTool import URLTool
from Products.CMFDefault.RegistrationTool import RegistrationTool
from Products.CMFDefault.MembershipTool import MembershipTool
-from AccessControl import SecurityManager
-from AccessControl.SecurityManagement import newSecurityManager
-import ZPublisher.HTTPRequest
-from Testing.makerequest import makerequest
-from Acquisition import Implicit
-
-class UnitTestUser( Implicit ):
- """
- Stubbed out manager for unit testing purposes.
- """
- id = 'unit_tester'
-
- def getId( self ):
- return self.id
-
- getUserName = getId
-
- def allowed( self, object, object_roles=None ):
- return 1
-
-class UnitTestSecurityPolicy:
- """
- Stub out the existing security policy for unit testing purposes.
- """
- #
- # Standard SecurityPolicy interface
- #
- def validate( self
- , accessed=None
- , container=None
- , name=None
- , value=None
- , context=None
- , roles=None
- , *args
- , **kw):
- return 1
-
- def checkPermission( self, permission, object, context) :
- return 1
-class ActionsToolTests( TestCase ):
+class ActionsToolTests( SecurityRequestTest ):
def setUp( self ):
- get_transaction().begin()
- self._policy = UnitTestSecurityPolicy()
- self._oldPolicy = SecurityManager.setSecurityPolicy(self._policy)
- self.connection = Zope.DB.open()
- self.root = root = self.connection.root()[ 'Application' ]
- newSecurityManager( None, UnitTestUser().__of__( self.root ) )
- root = self.root = makerequest(root)
+ SecurityRequestTest.setUp(self)
+ root = self.root
root._setObject( 'portal_actions', ActionsTool() )
root._setObject('foo', URLTool() )
self.tool = root.portal_actions
self.ut = root.foo
self.tool.action_providers = ('portal_actions',)
-
- def tearDown(self):
- SecurityManager.setSecurityPolicy( self._oldPolicy )
- get_transaction().abort()
- self.connection.close()
-
def test_actionProviders(self):
tool = self.tool
self.assertEqual(tool.listActionProviders(), ('portal_actions',))
@@ -137,8 +90,5 @@
makeSuite(ActionsToolTests),
))
-def run():
- main(defaultTest='test_suite')
-
if __name__ == '__main__':
- run()
+ main(defaultTest='test_suite')