[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Workflow/tests - testWorkflowService.py:1.2.24.2
Grégoire Weber
zope@i-con.ch
Wed, 4 Dec 2002 12:06:57 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Workflow/tests
In directory cvs.zope.org:/tmp/cvs-serv15463/tests
Modified Files:
Tag: sprintathon-wf-branch
testWorkflowService.py
Log Message:
first steps for workflow service unit tests
=== Zope3/lib/python/Zope/App/Workflow/tests/testWorkflowService.py 1.2.24.1 => 1.2.24.2 ===
--- Zope3/lib/python/Zope/App/Workflow/tests/testWorkflowService.py:1.2.24.1 Wed Dec 4 04:30:24 2002
+++ Zope3/lib/python/Zope/App/Workflow/tests/testWorkflowService.py Wed Dec 4 12:06:57 2002
@@ -11,28 +11,124 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
import unittest
from Interface import Interface
from Interface.Verify import verifyClass
+from Zope.ComponentArchitecture \
+ import getServiceManager, getService
+from Zope.ComponentArchitecture.GlobalServiceManager \
+ import serviceManager, defineService
+
+from Zope.App.OFS.Services.ConfigurationInterfaces \
+ import Active, Unregistered, Registered
+
+from Zope.App.OFS.Services.ServiceManager.ServiceManager \
+ import ServiceManager
+from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup \
+ import PlacefulSetup
+from Zope.App.OFS.Services.ServiceManager.ServiceConfiguration \
+ import ServiceConfiguration
+from Zope.App.Traversing import traverse
+
from Zope.App.Workflow.IWorkflowService import IWorkflowService
from Zope.App.Workflow.WorkflowService import WorkflowService
+from Zope.App.Workflow.WorkflowProcessDefinitionConfiguration \
+ import WorkflowProcessDefinitionConfiguration
+
+
+# define and create dummy ProcessDefinition (PD) for tests
+class IDummyProcessDefinition(Interface):
+ pass
+
+class DummyProcessDefinition:
+ __implements__ = IDummyProcessDefinition
+
+
+
+class WorkflowServiceTests(PlacefulSetup, unittest.TestCase):
+
+ # override the PlacefulSetup's testServiceManager by a real
+ # ServiceManager
+ def createServiceManager(self):
+ self.rootFolder.setServiceManager(ServiceManager())
+
+ def setUp(self):
+ PlacefulSetup.setUp(self)
+ self.buildFolders()
+
+ # we say to the global service manager that there is
+ # a workflow service which fullfills IWorkflowService
+ root_sm = getServiceManager(None)
+ root_sm.defineService('Workflows', IWorkflowService)
+
+ # create a service manager in rootFolder (default)
+ self.createServiceManager()
+ self.sm = sm = traverse(self.rootFolder, '++etc++Services')
+ self.default = default = traverse(sm, 'Packages/default')
+
+ ws = WorkflowService()
+ default.setObject('ws', ws)
+ configuration = ServiceConfiguration(
+ 'Workflows', '/++etc++Services/Packages/default/ws')
-class WorkflowServiceTests(unittest.TestCase):
+ default['configure'].setObject('', configuration)
+ traverse(default, 'configure/1').status = Active
- def createService(self):
- service = WorkflowService()
- return service
+ self.ws = getService(self.rootFolder, 'Workflows')
+ def setupProcessDefinitions(self):
+ default = self.default
+ # create process definition in the default package
+ pd1 = DummyProcessDefinition()
+ default.setObject('pd1', pd1)
+
+ #
+ configuration = WorkflowProcessDefinitionConfiguration(
+ 'pd1_name', '/++etc++Services/Packages/default/pd1')
+
+ default['configure'].setObject('', configuration)
+ traverse(default, 'configure/2').status = Active
+
+ #
+ pd2 = DummyProcessDefinition()
+ self.default.setObject('pd2', pd2)
+
+ #
+ configuration = WorkflowProcessDefinitionConfiguration(
+ 'pd2_name', '/++etc++Services/Packages/default/pd2')
+
+ default['configure'].setObject('', configuration)
+ traverse(default, 'configure/3').status = Active
+
+ return pd1, pd2
+
+ def dont_testGetProcessDefiniton(self):
+ pd1, pd2 = self.setupProcessDefinitions()
+
+ self.assertEqual(pd1, self.ws.getProcessDefinition('pd1_name'))
+ self.assertEqual(pd2, self.ws.getProcessDefinition('pd2_name'))
+
+ def testGetProcessDefinitonNames(self):
+ self.setupProcessDefinitions()
+
+ pd1_name, pd2_name = self.ws.getProcessDefinitionNames()
+ self.assertEqual(pd1_name, 'pd1_name')
+ self.assertEqual(pd2_name, 'pd2_name')
+
+
+ """
def testInterface(self):
verifyClass(IWorkflowService, WorkflowService)
-
- def testGetEngine(self):
- service = self.createService()
- #self.assertEqual(service.getEngine(engineInterface), [])
+ """
def test_suite():