[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/tests - __init__.py:1.2 test_workflowaction.py:1.2 test_workflowactivityinfo.py:1.2 test_workflowengine.py:1.2 test_workflowprocessinstance.py:1.2 test_workflowservice.py:1.2 test_workflowworkitem.py:1.2

Jim Fulton jim@zope.com
Wed, 25 Dec 2002 09:14:02 -0500


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

Added Files:
	__init__.py test_workflowaction.py 
	test_workflowactivityinfo.py test_workflowengine.py 
	test_workflowprocessinstance.py test_workflowservice.py 
	test_workflowworkitem.py 
Log Message:
Grand renaming:

- Renamed most files (especially python modules) to lower case.

- Moved views and interfaces into separate hierarchies within each
  project, where each top-level directory under the zope package
  is a separate project.

- Moved everything to src from lib/python.

  lib/python will eventually go away. I need access to the cvs
  repository to make this happen, however.

There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.



=== Zope3/src/zope/app/workflow/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/workflow/tests/__init__.py	Wed Dec 25 09:13:31 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/app/workflow/tests/test_workflowaction.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/workflow/tests/test_workflowaction.py	Wed Dec 25 09:13:31 2002
@@ -0,0 +1,169 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+
+class WorkflowActionTestsBase:
+
+    def test_getAction( self ):
+        ACTION = []
+        event = self._makeOne( ACTION )
+        self.assertEqual( event.getAction(), ACTION )
+
+    def _makeOne( self, *args, **kw ):
+
+        return self._getEventClass()( *args, **kw )
+
+class WorkflowActionCreatedTests( unittest.TestCase, WorkflowActionTestsBase ):
+
+    def testInterface( self ):
+        from zope.app.interfaces.workflow import IWorkflowEvent
+        from zope.app.interfaces.workflow import IWorkflowActionEvent
+        from zope.app.interfaces.workflow \
+            import IWorkflowActionCreatedEvent
+        from zope.app.workflow.workflowevents import WorkflowActionCreatedEvent
+        from zope.interface.verify import verifyClass
+
+        verifyClass( IWorkflowEvent, WorkflowActionCreatedEvent )
+        verifyClass( IWorkflowActionEvent, WorkflowActionCreatedEvent )
+        verifyClass( IWorkflowActionCreatedEvent, WorkflowActionCreatedEvent )
+
+    def _getEventClass( self ):
+        from zope.app.workflow.workflowevents import WorkflowActionCreatedEvent
+        return WorkflowActionCreatedEvent
+
+
+class WorkflowActionAssignedEventTest( unittest.TestCase
+                                     , WorkflowActionTestsBase ):
+
+    def testInterface( self ):
+        from zope.app.interfaces.workflow import IWorkflowEvent
+        from zope.app.interfaces.workflow import IWorkflowActionEvent
+        from zope.app.interfaces.workflow \
+            import IWorkflowActionAssignedEvent
+        from zope.app.workflow.workflowevents \
+            import WorkflowActionAssignedEvent
+        from zope.interface.verify import verifyClass
+
+        verifyClass( IWorkflowEvent, WorkflowActionAssignedEvent )
+        verifyClass( IWorkflowActionEvent, WorkflowActionAssignedEvent )
+        verifyClass( IWorkflowActionAssignedEvent, WorkflowActionAssignedEvent )
+
+    def _getEventClass( self ):
+        from zope.app.workflow.workflowevents import WorkflowActionAssignedEvent
+        return WorkflowActionAssignedEvent
+
+
+class WorkflowActionBegunEventTest( unittest.TestCase, WorkflowActionTestsBase ):
+
+    def testInterface( self ):
+        from zope.app.interfaces.workflow import IWorkflowEvent
+        from zope.app.interfaces.workflow import IWorkflowActionEvent
+        from zope.app.interfaces.workflow import IWorkflowActionBegunEvent
+        from zope.app.workflow.workflowevents import WorkflowActionBegunEvent
+        from zope.interface.verify import verifyClass
+
+        verifyClass( IWorkflowEvent, WorkflowActionBegunEvent )
+        verifyClass( IWorkflowActionEvent, WorkflowActionBegunEvent )
+        verifyClass( IWorkflowActionBegunEvent, WorkflowActionBegunEvent )
+
+    def _getEventClass( self ):
+        from zope.app.workflow.workflowevents import WorkflowActionBegunEvent
+        return WorkflowActionBegunEvent
+
+
+class WorkflowActionSuspendedTests( unittest.TestCase, WorkflowActionTestsBase ):
+
+    def testInterface(self):
+        from zope.app.interfaces.workflow import IWorkflowEvent
+        from zope.app.interfaces.workflow import IWorkflowActionEvent
+        from zope.app.interfaces.workflow \
+             import IWorkflowActionSuspendedEvent
+        from zope.app.workflow.workflowevents \
+             import WorkflowActionSuspendedEvent
+        from zope.interface.verify import verifyClass
+
+        verifyClass( IWorkflowEvent, WorkflowActionSuspendedEvent )
+        verifyClass( IWorkflowActionEvent, WorkflowActionSuspendedEvent )
+        verifyClass( IWorkflowActionSuspendedEvent, WorkflowActionSuspendedEvent )
+
+    def _getEventClass( self ):
+        from zope.app.workflow.workflowevents \
+            import WorkflowActionSuspendedEvent
+        return WorkflowActionSuspendedEvent
+
+
+class WorkflowActionCompletedEvent(unittest.TestCase, WorkflowActionTestsBase):
+
+    def testInterface(self):
+        from zope.app.interfaces.workflow import IWorkflowEvent
+        from zope.app.interfaces.workflow import IWorkflowActionEvent
+        from zope.app.interfaces.workflow \
+            import IWorkflowActionCompletedEvent
+        from zope.app.workflow.workflowevents \
+            import WorkflowActionCompletedEvent
+        from zope.interface.verify import verifyClass
+
+        verifyClass(IWorkflowEvent, WorkflowActionCompletedEvent)
+        verifyClass(IWorkflowActionEvent, WorkflowActionCompletedEvent)
+        verifyClass(IWorkflowActionCompletedEvent, WorkflowActionCompletedEvent)
+
+    def _getEventClass( self ):
+        from zope.app.workflow.workflowevents \
+            import WorkflowActionCompletedEvent
+        return WorkflowActionCompletedEvent
+
+
+class WorkflowActionExceptionEvent(unittest.TestCase, WorkflowActionTestsBase):
+
+    def testInterface(self):
+        from zope.app.interfaces.workflow import IWorkflowEvent
+        from zope.app.interfaces.workflow import IWorkflowActionEvent
+        from zope.app.interfaces.workflow \
+            import IWorkflowActionExceptionEvent
+        from zope.app.workflow.workflowevents \
+            import WorkflowActionExceptionEvent
+        from zope.interface.verify import verifyClass
+
+        verifyClass(IWorkflowEvent, WorkflowActionExceptionEvent)
+        verifyClass(IWorkflowActionEvent, WorkflowActionExceptionEvent)
+        verifyClass(IWorkflowActionExceptionEvent, WorkflowActionExceptionEvent)
+
+    def _getEventClass( self ):
+        from zope.app.workflow.workflowevents \
+            import WorkflowActionExceptionEvent
+        return WorkflowActionExceptionEvent
+
+    def _getEventClass( self ):
+        from zope.app.workflow.workflowevents \
+            import WorkflowActionExceptionEvent
+        return WorkflowActionExceptionEvent
+
+
+def test_suite():
+
+    suite = unittest.TestSuite()
+    for klass in ( WorkflowActionCreatedTests
+                 , WorkflowActionAssignedEventTest
+                 , WorkflowActionBegunEventTest
+                 , WorkflowActionSuspendedTests
+                 , WorkflowActionCompletedEvent
+                 , WorkflowActionExceptionEvent
+                 ):
+        suite.addTest(
+            unittest.defaultTestLoader.loadTestsFromTestCase( klass ) )
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main()


=== Zope3/src/zope/app/workflow/tests/test_workflowactivityinfo.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/workflow/tests/test_workflowactivityinfo.py	Wed Dec 25 09:13:31 2002
@@ -0,0 +1,116 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+from zope.interface.verify import verifyClass
+
+class WorkflowActivityInfoTests(unittest.TestCase):
+
+    def testInterface(self):
+        from zope.app.interfaces.workflow \
+            import IWorkflowActivityInfo
+        from zope.app.workflow.workflowactivityinfo \
+            import WorkflowActivityInfo
+
+        verifyClass(IWorkflowActivityInfo, WorkflowActivityInfo)
+
+    def _getOne(self, *args, **kw):
+        from zope.app.workflow.workflowactivityinfo import WorkflowActivityInfo
+        return WorkflowActivityInfo(*args, **kw)
+
+    def testEmpty(self):
+        id = 'blah'
+        ai = self._getOne(id)
+        self.assertEqual(ai.getId(), id)
+        self.assertEqual(ai.getTitle(), '')
+        self.assertEqual(ai.getCategory(), '')
+        self.assertEqual(ai.getActionURL(), '')
+        self.assertEqual(len(ai.getPermissions()), 0)
+        self.assertEqual(len(ai.getRoles()), 0)
+        self.assertEqual(ai.getCondition(), None)
+        self.assertEqual(ai.getSource(), None)
+
+    def testTitle(self):
+        id = 'blah'
+        title = 'zoinx'
+        ai = self._getOne(id, title=title)
+        self.assertEqual(ai.getTitle(), title)
+
+    def testCategory(self):
+        id = 'blah'
+        category = 'foobar'
+        ai = self._getOne(id, category=category)
+        self.assertEqual(ai.getCategory(), category)
+
+    def testActionURL(self):
+        id = 'blah'
+        action_url = 'baz'
+        ai = self._getOne(id, action_url=action_url)
+        self.assertEqual(ai.getActionURL(), action_url)
+
+    def testPermissions(self):
+        id = 'blah'
+        permissions = [1,2,3]
+        ai = self._getOne(id, permissions=permissions)
+        self.assertEqual(ai.getPermissions(), permissions)
+
+    def testRoles(self):
+        id = 'blah'
+        roles = [4,5,6]
+        ai = self._getOne(id, roles=roles)
+        self.assertEqual(ai.getRoles(), roles)
+
+    def testCondition(self):
+        id = 'blah'
+        condition = []
+        ai = self._getOne(id, condition=condition)
+        self.assertEqual(ai.getCondition(), condition)
+
+    def testSource(self):
+        id = 'blah'
+        source = []
+        ai = self._getOne(id, source=source)
+        self.assertEqual(ai.getSource(), source)
+
+    def testComplex(self):
+        id = 'blah'
+        title = 'zoinx'
+        category = 'foobar'
+        action_url = 'baz'
+        permissions = [1,2,3]
+        roles = [4,5,6]
+        condition = []
+        source = []
+        ai = self._getOne(id, title=title, category=category,
+                          action_url=action_url, permissions=permissions,
+                          roles=roles, condition=condition,
+                          source=source)
+        self.assertEqual(ai.getId(), id)
+        self.assertEqual(ai.getTitle(), title)
+        self.assertEqual(ai.getCategory(), category)
+        self.assertEqual(ai.getActionURL(), action_url)
+        self.assertEqual(ai.getPermissions(), permissions)
+        self.assertEqual(ai.getRoles(), roles)
+        self.assertEqual(ai.getCondition(), condition)
+        self.assertEqual(ai.getSource(), source)
+
+def test_suite():
+
+    suite = unittest.TestSuite()
+    suite.addTest(
+        unittest.defaultTestLoader.loadTestsFromTestCase(
+            WorkflowActivityInfoTests ) )
+    return suite
+
+if __name__ == '__main__':
+    unittest.main()


=== Zope3/src/zope/app/workflow/tests/test_workflowengine.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/workflow/tests/test_workflowengine.py	Wed Dec 25 09:13:31 2002
@@ -0,0 +1,39 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+
+
+class WorkflowEngineTests( unittest.TestCase ):
+
+    def testInterface( self ):
+        from zope.app.interfaces.workflow import IWorkflowEngine
+        from zope.app.workflow.workflowengine import WorkflowEngine
+        from zope.interface.verify import verifyClass
+
+        verifyClass( IWorkflowEngine, WorkflowEngine )
+
+
+
+def test_suite():
+
+    suite = unittest.TestSuite()
+    suite.addTest(
+        unittest.defaultTestLoader.loadTestsFromTestCase(
+            WorkflowEngineTests ) )
+    return suite
+
+
+
+if __name__ == '__main__':
+    unittest.main()


=== Zope3/src/zope/app/workflow/tests/test_workflowprocessinstance.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/workflow/tests/test_workflowprocessinstance.py	Wed Dec 25 09:13:31 2002
@@ -0,0 +1,40 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+
+
+class WorkflowProcessInstanceTests( unittest.TestCase ):
+
+    def testInterface( self ):
+        from zope.interface.verify import verifyClass
+        from zope.app.interfaces.workflow \
+            import IWorkflowProcessInstance
+        from zope.app.workflow.workflowprocessinstance \
+            import WorkflowProcessInstance
+
+        verifyClass( IWorkflowProcessInstance, WorkflowProcessInstance )
+
+
+def test_suite():
+
+    suite = unittest.TestSuite()
+    suite.addTest(
+        unittest.defaultTestLoader.loadTestsFromTestCase(
+            WorkflowProcessInstanceTests ) )
+    return suite
+
+
+
+if __name__ == '__main__':
+    unittest.main()


=== Zope3/src/zope/app/workflow/tests/test_workflowservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/workflow/tests/test_workflowservice.py	Wed Dec 25 09:13:31 2002
@@ -0,0 +1,78 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+from zope.interface import Interface
+
+class engineInterface(Interface):
+    pass
+
+class dummyEngine:
+    __implements__ = engineInterface
+
+    def listActions( self ):
+        return [0, 1, 2]
+
+class WorkflowServiceTests( unittest.TestCase ):
+
+    def createService( self ):
+        from zope.app.workflow.workflowservice import WorkflowService
+        service = WorkflowService()
+        return service
+
+
+    def testInterface( self ):
+        from zope.app.interfaces.workflow import IWorkflowService
+        from zope.app.workflow.workflowservice import WorkflowService
+        from zope.interface.verify import verifyClass
+
+        verifyClass( IWorkflowService, WorkflowService )
+
+
+    def testGetEngine( self ):
+        service = self.createService()
+        self.assertEqual(service.getEngine(engineInterface), [])
+
+    def testAddEngine( self ):
+        service = self.createService()
+        engine = dummyEngine()
+        service.addEngine(engine)
+        self.assertEqual(service.getEngine(engineInterface), [engine])
+
+
+    def testRemoveEngine( self ):
+        service = self.createService()
+        engine = dummyEngine()
+        service.addEngine(engine)
+        service.removeEngine(engine)
+        self.assertEqual(service.getEngine(engineInterface), [])
+
+
+    def testListWorkflowEngineActions( self ):
+        service = self.createService()
+        engine = dummyEngine()
+        service.addEngine(engine)
+        self.assertEqual(service.listWorkflowEngineActions(),
+                         engine.listActions())
+
+
+def test_suite():
+
+    suite = unittest.TestSuite()
+    suite.addTest(
+        unittest.defaultTestLoader.loadTestsFromTestCase(
+            WorkflowServiceTests ) )
+    return suite
+
+if __name__ == '__main__':
+    unittest.main()


=== Zope3/src/zope/app/workflow/tests/test_workflowworkitem.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:02 2002
+++ Zope3/src/zope/app/workflow/tests/test_workflowworkitem.py	Wed Dec 25 09:13:31 2002
@@ -0,0 +1,109 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+from zope.interface.verify import verifyClass
+
+class WorkflowWorkitemTests(unittest.TestCase):
+    def testInterface(self):
+        from zope.app.interfaces.workflow import IWorkflowWorkitem
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem
+
+        verifyClass(IWorkflowWorkitem, WorkflowWorkitem)
+
+    def _getOne(self, *args, **kw):
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem
+        return WorkflowWorkitem(*args, **kw)
+
+    def testGetProcessInstance(self):
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem
+
+        pi = []
+        wi = self._getOne(pi)
+        npi = wi.getProcessInstance()
+        self.assertEqual(pi, npi)
+
+    def testEmpty(self):
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem, INIT
+
+        pi = []
+        wi = self._getOne(pi)
+        assignee = wi.getAssignee()
+        state = wi.getState()
+        self.assertEqual(assignee, None)
+        self.assertEqual(state, INIT)
+
+    def testAssignee(self):
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem
+
+        pi = []
+        wi = self._getOne(pi)
+        assignee = []
+        wi.assign(assignee)
+        nassignee = wi.getAssignee()
+        self.assertEqual(assignee, nassignee)
+
+    def testBegin(self):
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem, \
+             WorkflowWorkitemException, BEGUN
+
+        pi = []
+        wi = self._getOne(pi)
+        wi.begin()
+        state = wi.getState()
+        self.assertEqual(state, BEGUN)
+        self.assertRaises(WorkflowWorkitemException, wi.begin)
+
+    def testComplete(self):
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem, \
+             WorkflowWorkitemException, COMPLETED
+
+        pi = []
+        wi = self._getOne(pi)
+        self.assertRaises(WorkflowWorkitemException, wi.complete)
+        self.assertRaises(WorkflowWorkitemException, wi.fail)
+        wi.begin()
+        wi.complete()
+        state = wi.getState()
+        self.assertEqual(state, COMPLETED)
+        self.assertRaises(WorkflowWorkitemException, wi.begin)
+        self.assertRaises(WorkflowWorkitemException, wi.complete)
+        self.assertRaises(WorkflowWorkitemException, wi.fail)
+
+    def testFail(self):
+        from zope.app.workflow.workflowworkitem import WorkflowWorkitem, \
+             WorkflowWorkitemException, FAILED
+
+        pi = []
+        wi = self._getOne(pi)
+        self.assertRaises(WorkflowWorkitemException, wi.complete)
+        self.assertRaises(WorkflowWorkitemException, wi.fail)
+        wi.begin()
+        wi.fail()
+        state = wi.getState()
+        self.assertEqual(state, FAILED)
+        self.assertRaises(WorkflowWorkitemException, wi.begin)
+        self.assertRaises(WorkflowWorkitemException, wi.complete)
+        self.assertRaises(WorkflowWorkitemException, wi.fail)
+
+
+def test_suite():
+
+    suite = unittest.TestSuite()
+    suite.addTest(
+        unittest.defaultTestLoader.loadTestsFromTestCase(
+            WorkflowWorkitemTests ) )
+    return suite
+
+if __name__ == '__main__':
+    unittest.main()