[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/tests - directive_helpers.py:1.1.4.1 test_definition.py:1.1.4.1 test_directives.py:1.1.4.1 test_importexport.py:1.1.4.1 test_instance.py:1.1.4.1 test_service.py:1.1.4.1 workflowsetup.py:1.1.4.1

Grégoire Weber zope@i-con.ch
Sun, 22 Jun 2003 10:24:07 -0400


Update of /cvs-repository/Zope3/src/zope/app/workflow/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/workflow/tests

Modified Files:
      Tag: cw-mail-branch
	directive_helpers.py test_definition.py test_directives.py 
	test_importexport.py test_instance.py test_service.py 
	workflowsetup.py 
Log Message:
Synced up with HEAD

=== Zope3/src/zope/app/workflow/tests/directive_helpers.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/workflow/tests/directive_helpers.py:1.1	Thu May  8 13:27:20 2003
+++ Zope3/src/zope/app/workflow/tests/directive_helpers.py	Sun Jun 22 10:23:36 2003
@@ -15,10 +15,9 @@
 __metaclass__ = type
 
 from zope.app.interfaces.workflow import IProcessDefinition
-from zope.app.interfaces.workflow import IGlobalProcessDefinitionImportExport
 from zope.app.interfaces.workflow import IProcessDefinitionImportHandler
 from zope.app.interfaces.workflow import IProcessDefinitionExportHandler
-
+from zope.interface import implements
 
 
 class ITestProcessDefinitionA(IProcessDefinition):
@@ -30,7 +29,7 @@
 
 class TestImportHandlerA:
 
-    __implements__ = IProcessDefinitionImportHandler
+    implements(IProcessDefinitionImportHandler)
 
     def canImport(self, context, data):
         return bool(data.read() == 'A')
@@ -41,7 +40,7 @@
 
 class TestImportHandlerB:
 
-    __implements__ = IProcessDefinitionImportHandler
+    implements(IProcessDefinitionImportHandler)
 
     def canImport(self, context, data):
         return bool(data.read() == 'B')
@@ -50,10 +49,9 @@
         return 'Imported B'
 
 
-
 class TestExportHandlerA:
 
-    __implements__ = IProcessDefinitionExportHandler
+    implements(IProcessDefinitionExportHandler)
 
     def doExport(self, context, process_definition):
         return 'Exported A'
@@ -61,7 +59,7 @@
 
 class TestExportHandlerB:
 
-    __implements__ = IProcessDefinitionExportHandler
+    implements(IProcessDefinitionExportHandler)
 
     def doExport(self, context, process_definition):
         return 'Exported B'


=== Zope3/src/zope/app/workflow/tests/test_definition.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/workflow/tests/test_definition.py:1.1	Thu May  8 13:27:20 2003
+++ Zope3/src/zope/app/workflow/tests/test_definition.py	Sun Jun 22 10:23:36 2003
@@ -14,7 +14,6 @@
 
 import unittest
 
-from zope.interface import Interface
 from zope.interface.verify import verifyClass
 
 from zope.app.interfaces.workflow import IProcessDefinition


=== Zope3/src/zope/app/workflow/tests/test_directives.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/workflow/tests/test_directives.py:1.1	Thu May  8 13:27:20 2003
+++ Zope3/src/zope/app/workflow/tests/test_directives.py	Sun Jun 22 10:23:36 2003
@@ -13,8 +13,6 @@
 ##############################################################################
 
 import unittest
-import sys
-import os
 from cStringIO import StringIO
 
 from zope.app.tests.placelesssetup import PlacelessSetup


=== Zope3/src/zope/app/workflow/tests/test_importexport.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/workflow/tests/test_importexport.py:1.1	Thu May  8 13:27:20 2003
+++ Zope3/src/zope/app/workflow/tests/test_importexport.py	Sun Jun 22 10:23:36 2003
@@ -13,27 +13,24 @@
 ##############################################################################
 
 import unittest
-import sys
-import os
-from cStringIO import StringIO
 
 from zope.app.tests.placelesssetup import PlacelessSetup
 
 from zope.app.workflow import globalimportexport
 from zope.app.workflow.tests import directive_helpers
 
+from zope.interface import implements
+
 gIE = globalimportexport.globalImportExport
 dh = directive_helpers
 
 class PDA:
 
-    __implements__ = dh.ITestProcessDefinitionA
+    implements(dh.ITestProcessDefinitionA)
 
 class PDB:
 
-    __implements__ = dh.ITestProcessDefinitionB
-
-
+    implements(dh.ITestProcessDefinitionB)
 
 
 class Test(PlacelessSetup, unittest.TestCase):
@@ -63,9 +60,7 @@
                          'Exported A')
         self.assertEqual(gIE.exportProcessDefinition(None, PDB()),
                          'Exported B')
-        
 
-        
 
 def test_suite():
     loader=unittest.TestLoader()


=== Zope3/src/zope/app/workflow/tests/test_instance.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/workflow/tests/test_instance.py:1.1	Thu May  8 13:27:20 2003
+++ Zope3/src/zope/app/workflow/tests/test_instance.py	Sun Jun 22 10:23:36 2003
@@ -23,10 +23,11 @@
 
 from zope.app.interfaces.workflow import IProcessInstanceContainer
 from zope.app.workflow.instance import ProcessInstanceContainerAdapter, WFKey
+from zope.interface import implements
 
 class TestAnnotations(dict):
 
-    __implements__ = IAnnotations
+    implements(IAnnotations)
 
 class DummyInstance:
     pass
@@ -38,7 +39,6 @@
         verifyClass(IProcessInstance, ProcessInstance)
 
 
-
 class ProcessInstanceContainerAdapterTests(PlacelessSetup, unittest.TestCase):
 
     def testInterface(self):
@@ -58,7 +58,7 @@
         self.assertEqual(pica.values(), [])
         self.assertEqual(pica.get('nothing', 1), 1)
         self.assertRaises(TypeError, pica.setObject, 123, None)
-        
+
         pica.setObject('dummy', di)
         self.assertEqual(len(pica), 1)
         self.assertEqual(pica.keys(), ['dummy'])
@@ -72,11 +72,6 @@
 
         self.assertEqual(len(pica), 0)
         self.failIf('dummy' in pica)
-        
-        
-
-
-
 
 
 def test_suite():


=== Zope3/src/zope/app/workflow/tests/test_service.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/workflow/tests/test_service.py:1.1	Thu May  8 13:27:20 2003
+++ Zope3/src/zope/app/workflow/tests/test_service.py	Sun Jun 22 10:23:36 2003
@@ -19,37 +19,42 @@
 
 import unittest
 
-from zope.interface import Interface
+from zope.app import zapi
+from zope.interface import implements
 from zope.interface.verify import verifyClass
 
-from zope.app.traversing import traverse
-from zope.app.container.zopecontainer import ZopeContainerAdapter
 from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.interfaces.services.configuration \
-     import IUseConfigurable
-
-from zope.app.interfaces.services.configuration \
-     import Active, Unregistered, Registered
+from zope.app.interfaces.services.registration import IRegisterable
+from zope.app.interfaces.services.registration import IRegistered
+from zope.app.interfaces.services.registration import RegisteredStatus
+from zope.app.interfaces.services.registration import ActiveStatus
 
 from zope.app.workflow.tests.workflowsetup import WorkflowSetup
 from zope.app.interfaces.workflow \
      import IWorkflowService, IProcessDefinition
 from zope.app.workflow.service import WorkflowService
-from zope.app.workflow.service import ProcessDefinitionConfiguration
+from zope.app.workflow.service import ProcessDefinitionRegistration
 
 # define and create dummy ProcessDefinition (PD) for tests
 class DummyProcessDefinition:
-    __implements__ = IProcessDefinition, IAttributeAnnotatable, IUseConfigurable
+    implements(IProcessDefinition, IAttributeAnnotatable, IRegisterable,
+               IRegistered)
 
     def __init__(self, n):
         self.n = n
 
     def __str__(self):
         return'PD #%d' % self.n
-    
+
     def createProcessInstance(self, definition_name):
         return 'PI #%d' % self.n
 
+    # Implements (incompletely) IRegistered to satisfy the promise that
+    # it is IRegisterable.
+    # Only the method addUsage is implemented.
+    def addUsage(self, location):
+        pass
+
 
 def sort(l):
     l = [str(d) for d in l]
@@ -64,60 +69,87 @@
         self.default.setObject('pd1', DummyProcessDefinition(1))
         self.default.setObject('pd2', DummyProcessDefinition(2))
 
-        self.cm.setObject('', ProcessDefinitionConfiguration('definition1',
+        self.cm.setObject('', ProcessDefinitionRegistration('definition1',
                                 '/++etc++site/default/pd1'))
-        traverse(self.default.getConfigurationManager(), '2').status = Active
-        self.cm.setObject('', ProcessDefinitionConfiguration('definition2',
+        zapi.traverse(self.default.getRegistrationManager(),
+                      '2').status = ActiveStatus
+        self.cm.setObject('', ProcessDefinitionRegistration('definition2',
                                 '/++etc++site/default/pd2'))
-        traverse(self.default.getConfigurationManager(), '3').status = Active
-        self.cm.setObject('', ProcessDefinitionConfiguration('definition3',
+        zapi.traverse(self.default.getRegistrationManager(),
+                      '3').status = ActiveStatus
+        self.cm.setObject('', ProcessDefinitionRegistration('definition3',
                                 '/++etc++site/default/pd1'))
-        traverse(self.default.getConfigurationManager(), '4').status = Registered
+        zapi.traverse(self.default.getRegistrationManager(),
+                 '4').status = RegisteredStatus
         # Now self.service has definition1 and definition2 available
         # and knows about definition3
 
         self.default1.setObject('pd3', DummyProcessDefinition(3))
         self.default1.setObject('pd4', DummyProcessDefinition(4))
 
-        self.cm1.setObject('', ProcessDefinitionConfiguration('definition1',
+        self.cm1.setObject('', ProcessDefinitionRegistration('definition1',
                             '/folder1/++etc++site/default/pd3'))
-        traverse(self.default1.getConfigurationManager(), '2').status = Active
-        self.cm1.setObject('', ProcessDefinitionConfiguration('definition4',
+        zapi.traverse(self.default1.getRegistrationManager(),
+                      '2').status = ActiveStatus
+        self.cm1.setObject('', ProcessDefinitionRegistration('definition4',
                             '/folder1/++etc++site/default/pd4'))
-        traverse(self.default1.getConfigurationManager(), '3').status = Active
-        # Now self.service1 overrides definition1, adds new definition4 available,
-        # and inherits definition2 from self.service
+        zapi.traverse(self.default1.getRegistrationManager(),
+                      '3').status = ActiveStatus
+        # Now self.service1 overrides definition1, adds new definition4
+        # available, and inherits definition2 from self.service
 
     def testInterface(self):
         verifyClass(IWorkflowService, WorkflowService)
 
     def testGetProcessDefiniton(self):
-        self.assertEqual('PD #1', str(self.service.getProcessDefinition('definition1')))
-        self.assertEqual('PD #2', str(self.service.getProcessDefinition('definition2')))
-        self.assertRaises(KeyError, self.service.getProcessDefinition, 'definition3')
-        self.assertRaises(KeyError, self.service.getProcessDefinition, 'definition4')
-                          
-        self.assertEqual('PD #3', str(self.service1.getProcessDefinition('definition1')))
-        self.assertEqual('PD #2', str(self.service1.getProcessDefinition('definition2')))
-        self.assertRaises(KeyError, self.service1.getProcessDefinition, 'definition3')
-        self.assertEqual('PD #4', str(self.service1.getProcessDefinition('definition4')))
-        self.assertRaises(KeyError, self.service1.getProcessDefinition, 'definition5')
+        self.assertEqual(
+            'PD #1', str(self.service.getProcessDefinition('definition1')))
+        self.assertEqual(
+            'PD #2', str(self.service.getProcessDefinition('definition2')))
+        self.assertRaises(
+            KeyError, self.service.getProcessDefinition, 'definition3')
+        self.assertRaises(
+            KeyError, self.service.getProcessDefinition, 'definition4')
+
+        self.assertEqual(
+            'PD #3', str(self.service1.getProcessDefinition('definition1')))
+        self.assertEqual(
+            'PD #2', str(self.service1.getProcessDefinition('definition2')))
+        self.assertRaises(
+            KeyError, self.service1.getProcessDefinition, 'definition3')
+        self.assertEqual(
+            'PD #4', str(self.service1.getProcessDefinition('definition4')))
+        self.assertRaises(
+            KeyError, self.service1.getProcessDefinition, 'definition5')
 
     def testQueryProcessDefinition(self):
-        self.assertEqual('PD #1', str(self.service.queryProcessDefinition('definition1')))
-        self.assertEqual('PD #2', str(self.service.queryProcessDefinition('definition2')))
-        self.assertEqual(None, self.service.queryProcessDefinition('definition3'))
-        self.assertEqual('xx', self.service.queryProcessDefinition('definition3', 'xx'))
-        self.assertEqual(None, self.service.queryProcessDefinition('definition4'))
-        self.assertEqual('xx', self.service.queryProcessDefinition('definition4', 'xx'))
-
-        self.assertEqual('PD #3', str(self.service1.queryProcessDefinition('definition1')))
-        self.assertEqual('PD #2', str(self.service1.queryProcessDefinition('definition2')))
-        self.assertEqual(None, self.service1.queryProcessDefinition('definition3'))
-        self.assertEqual('xx', self.service1.queryProcessDefinition('definition3', 'xx'))
-        self.assertEqual('PD #4', str(self.service1.queryProcessDefinition('definition4')))
-        self.assertEqual(None, self.service1.queryProcessDefinition('definition5'))
-        self.assertEqual('xx', self.service1.queryProcessDefinition('definition5', 'xx'))
+        self.assertEqual(
+            'PD #1', str(self.service.queryProcessDefinition('definition1')))
+        self.assertEqual(
+            'PD #2', str(self.service.queryProcessDefinition('definition2')))
+        self.assertEqual(
+            None, self.service.queryProcessDefinition('definition3'))
+        self.assertEqual(
+            'xx', self.service.queryProcessDefinition('definition3', 'xx'))
+        self.assertEqual(
+            None, self.service.queryProcessDefinition('definition4'))
+        self.assertEqual(
+            'xx', self.service.queryProcessDefinition('definition4', 'xx'))
+
+        self.assertEqual(
+            'PD #3', str(self.service1.queryProcessDefinition('definition1')))
+        self.assertEqual(
+            'PD #2', str(self.service1.queryProcessDefinition('definition2')))
+        self.assertEqual(
+            None, self.service1.queryProcessDefinition('definition3'))
+        self.assertEqual(
+            'xx', self.service1.queryProcessDefinition('definition3', 'xx'))
+        self.assertEqual(
+            'PD #4', str(self.service1.queryProcessDefinition('definition4')))
+        self.assertEqual(
+            None, self.service1.queryProcessDefinition('definition5'))
+        self.assertEqual(
+            'xx', self.service1.queryProcessDefinition('definition5', 'xx'))
 
 
     def testGetProcessDefinitonNames(self):


=== Zope3/src/zope/app/workflow/tests/workflowsetup.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/workflow/tests/workflowsetup.py:1.1	Thu May  8 13:27:20 2003
+++ Zope3/src/zope/app/workflow/tests/workflowsetup.py	Sun Jun 22 10:23:36 2003
@@ -16,105 +16,55 @@
 Revision information:
 $Id$
 """
-from zope.app.traversing import traverse, getPath
-from zope.app.container.zopecontainer import ZopeContainerAdapter
-from zope.app.services.service import ServiceManager
-from zope.app.services.service import ServiceConfiguration
 
 from zope.component import getService, getServiceManager
-from zope.app.services.servicenames import Roles, Permissions, Adapters
+from zope.app.services.servicenames import Roles, Permissions
 from zope.app.services.servicenames import Authentication, Workflows
 
 from zope.app.interfaces.security import IAuthenticationService
 from zope.app.interfaces.security import IRoleService
 from zope.app.interfaces.security import IPermissionService
-from zope.app.security.registries.principalregistry \
-     import principalRegistry
-from zope.app.security.registries.permissionregistry \
-     import permissionRegistry
-
-from zope.app.interfaces.dependable import IDependable
-from zope.app.services.tests.placefulsetup \
-     import PlacefulSetup
-from zope.app.interfaces.annotation import IAnnotatable
-from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.interfaces.annotation import IAnnotations
-from zope.app.interfaces.dependable import IDependable
-from zope.app.dependable import Dependable
-from zope.app.interfaces.services.configuration \
-     import IUseConfiguration, IUseConfigurable
-from zope.app.services.configuration import UseConfiguration
-from zope.component.adapter import provideAdapter
+from zope.app.security.registries.principalregistry import principalRegistry
+from zope.app.security.registries.permissionregistry import permissionRegistry
 
-from zope.app.interfaces.services.configuration \
-     import Active, Unregistered, Registered
+from zope.app.services.tests.placefulsetup import PlacefulSetup
+from zope.app.interfaces.annotation import IAttributeAnnotatable
 
 from zope.app.workflow.service import WorkflowService
 
+from zope.interface import implements
 
+from zope.app.tests import setup
 
+from zope.app import zapi
 
 class WorkflowServiceForTests(WorkflowService):
 
-    __implements__ = WorkflowService.__implements__, IAttributeAnnotatable
-
-
+    implements(IAttributeAnnotatable)
 
 
 class WorkflowSetup(PlacefulSetup):
 
     def setUp(self):
-        PlacefulSetup.setUp(self)
-
         self.root_sm = getServiceManager(None)
 
-        provideAdapter(IAttributeAnnotatable,
-                       IAnnotations, AttributeAnnotations)
-        provideAdapter(IAnnotatable, IDependable, Dependable)
-        provideAdapter(IUseConfigurable, IUseConfiguration, UseConfiguration)
-        
-        # Set up a local workflow service
-        self.buildFolders()
-        self.rootFolder.setServiceManager(ServiceManager())
-
-        service_name = 'workflow_srv'
-        self.sm = traverse(self.rootFolder, '++etc++site')
-        self.default = default = traverse(self.sm, 'default')
-        default.setObject(service_name, WorkflowServiceForTests())
-
-        # XXX change to unique names 
-        self.service = traverse(default, service_name)
-        path = "%s/%s" % (getPath(default), service_name)
-        configuration = ServiceConfiguration(Workflows, path, self.rootFolder)
-        self.cm = default.getConfigurationManager()
-        self.cm.setObject('', configuration)
-        traverse(self.cm, '1').status = Active
-
-        # Set up a more local workflow service
-        folder1 = traverse(self.rootFolder, 'folder1')
-        folder1.setServiceManager(ServiceManager())
-
-        service_name1 = 'workflow_srv1'
-        self.sm1 = traverse(folder1, '++etc++site')
-        self.default1 = default1 = traverse(self.sm1, 'default')
-        default1.setObject(service_name1, WorkflowServiceForTests())
-
-        # XXX change to unique name
-        self.service1 = traverse(self.default1, service_name1)
-        path1 = "%s/%s" % (getPath(default1), service_name1)
-        configuration1 = ServiceConfiguration(Workflows, path1, self.rootFolder)
-        self.cm1 = default1.getConfigurationManager()
-        self.cm1.setObject('', configuration1)
-        traverse(self.cm1, '1').status = Active
-
+        self.sm = PlacefulSetup.setUp(self, site=True)
+        self.service = setup.addService(self.sm, Workflows,
+                                        WorkflowServiceForTests())
+        self.default = zapi.traverse(self.sm, "default")
+        self.cm = self.default.getRegistrationManager()
+
+        self.sm1 = self.makeSite('folder1')
+        self.service1 = setup.addService(self.sm1, Workflows,
+                                         WorkflowServiceForTests())
+        self.default1 = zapi.traverse(self.sm1, "default")
+        self.cm1 = self.default1.getRegistrationManager()
 
     def setupAuthService(self):
         self.root_sm.defineService(Authentication, IAuthenticationService)
         self.root_sm.provideService(Authentication, principalRegistry)
         return getService(self.rootFolder, Authentication)
 
-
     def setupRoleService(self):
         self.root_sm.defineService(Roles, IRoleService)
         self.root_sm.provideService(Roles, roleRegistry)
@@ -124,6 +74,4 @@
         self.root_sm.defineService(Permissions, IPermissionService)
         self.root_sm.provideService(Permissions, permissionRegistry)
         return getService(self.rootFolder, Permissions)
-
-