[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful/tests -
test_instance.py:1.14 test_xmlimportexport.py:1.12
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Mar 8 07:07:05 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful/tests
In directory cvs.zope.org:/tmp/cvs-serv13053/src/zope/app/workflow/stateful/tests
Modified Files:
test_instance.py test_xmlimportexport.py
Log Message:
Adjusted code to use the new APIs for permissions and principals. Also, use
the utility service instead of the permission registry to look up permissions.
=== Zope3/src/zope/app/workflow/stateful/tests/test_instance.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/workflow/stateful/tests/test_instance.py:1.13 Fri Mar 5 17:09:24 2004
+++ Zope3/src/zope/app/workflow/stateful/tests/test_instance.py Mon Mar 8 07:06:25 2004
@@ -24,10 +24,8 @@
from zope.component.service import serviceManager
from zope.app.event.tests.placelesssetup import \
eventPublisher, EventRecorder, events, clearEvents
-from zope.app.interfaces.security import IPermissionService
-from zope.app.security.registries.permissionregistry \
- import permissionRegistry
-from zope.app.services.servicenames import Permissions
+from zope.app.security.interfaces import IPermission
+from zope.app.security.permission import Permission
from zope.security.checker import CheckerPublic
from zope.security.management import newSecurityManager
@@ -50,6 +48,7 @@
from zope.app.workflow.stateful.instance \
import StatefulProcessInstance, StateChangeInfo
from zope.app import zapi
+from zope.app.tests import ztapi
from zope.app.container.contained import contained
from zope.app.services.utility import UtilityRegistration
@@ -352,11 +351,8 @@
def setUp(self):
WorkflowSetup.setUp(self)
- serviceManager.defineService(Permissions, IPermissionService)
- serviceManager.provideService(Permissions, permissionRegistry)
- permissionRegistry.definePermission('deny', 'Deny')
+ ztapi.provideUtility(IPermission, Permission('deny', 'Deny'), 'deny')
- #newSecurityManager(system_user)
newSecurityManager('test')
pd = TestProcessDefinition()
=== Zope3/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py:1.11 Sat Mar 6 11:50:37 2004
+++ Zope3/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py Mon Mar 8 07:06:25 2004
@@ -11,31 +11,34 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""XML import/export tests
+$Id$
+"""
+import unittest
from StringIO import StringIO
+
+from zope.app import zapi
from zope.app.attributeannotations import AttributeAnnotations
from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
from zope.app.interfaces.annotation import IAnnotatable, IAnnotations
from zope.app.interfaces.annotation import IAttributeAnnotatable
from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.interfaces.security import IPermissionService
+from zope.app.security.interfaces import IPermission
from zope.app.interfaces.services.registration import IRegisterable
from zope.app.workflow.interfaces import IProcessDefinitionExportHandler
from zope.app.workflow.interfaces import IProcessDefinitionImportHandler
-from zope.app.security.registries.permissionregistry import permissionRegistry
-from zope.app.services.servicenames import Permissions
+from zope.app.security.permission import Permission
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.workflow.stateful.definition import StatefulProcessDefinition
from zope.app.workflow.stateful.definition import State, Transition
from zope.app.workflow.stateful.xmlimportexport import XMLExportHandler
from zope.app.workflow.stateful.xmlimportexport import XMLImportHandler
from zope.app.tests import ztapi
-from zope.component import getService, getServiceManager
from zope.interface import implements, classImplements, Interface
from zope.interface.verify import verifyClass
from zope.schema import TextLine
from zope.security.checker import CheckerPublic
-import unittest
class ISchema(Interface):
@@ -107,11 +110,8 @@
AttributeAnnotations)
ztapi.provideAdapter(IAnnotatable, IZopeDublinCore,
ZDCAnnotatableAdapter)
- sm = getServiceManager(None)
- sm.defineService(Permissions, IPermissionService)
- sm.provideService(Permissions, permissionRegistry)
- perm_service = getService(None, Permissions)
- perm_service.definePermission('zope.View', 'View', '')
+ ztapi.provideUtility(IPermission, Permission('zope.View', 'View', ''),
+ 'zope.View')
def testInterface(self):
verifyClass(IProcessDefinitionImportHandler, XMLImportHandler)
@@ -133,10 +133,9 @@
self.assertEqual(testpd.relevantDataSchema, ISchema)
self.assertEqual(IZopeDublinCore(testpd).title, 'TestPD')
- perm_service = getService(None, Permissions)
self.assertEqual(
testpd.schemaPermissions['title'],
- (CheckerPublic, perm_service.getPermission('zope.View')))
+ (CheckerPublic, zapi.getUtility(None, IPermission, 'zope.View')))
self.assertEqual(len(testpd.states), 3)
self.assertEqual(len(testpd.transitions), 3)
More information about the Zope3-Checkins
mailing list