[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Workflow/tests - testWorkflowAction.py:1.1.2.6

Tres Seaver tseaver@zope.com
Tue, 5 Mar 2002 06:23:22 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Workflow/tests
In directory cvs.zope.org:/tmp/cvs-serv2508/tests

Modified Files:
      Tag: Zope-3x-branch
	testWorkflowAction.py 
Log Message:
 - Refactor duplication (tests, implementation) into base classes.

=== Zope3/lib/python/Zope/App/Workflow/tests/testWorkflowAction.py 1.1.2.5 => 1.1.2.6 ===
 
-class WorkflowActionCreatedTests( unittest.TestCase ):
+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.Workflow.IWorkflowEvents import IWorkflowEvent
@@ -12,17 +23,42 @@
         verify( IWorkflowEvent, WorkflowActionCreatedEvent )
         verify( IWorkflowActionCreatedEvent, WorkflowActionCreatedEvent )
 
-    def _makeOne( self, *args, **kw ):
+    def _getEventClass( self ):
         from Zope.App.Workflow.WorkflowEvents import WorkflowActionCreatedEvent
-        return WorkflowActionCreatedEvent( *args, **kw )
+        return WorkflowActionCreatedEvent
 
-    def test_getAction( self ):
-        ACTION = []
-        event = self._makeOne( ACTION )
-        self.assertEqual( event.getAction(), ACTION )
+
+class WorkflowActionAssignedEventTest( unittest.TestCase, WorkflowActionTestsBase ):
+
+    def testInterface( self ):
+        from Zope.App.Workflow.IWorkflowEvents \
+            import IWorkflowActionAssignedEvent
+        from Zope.App.Workflow.WorkflowEvents \
+            import WorkflowActionAssignedEvent
+        from Interface import verify
+        
+        verify( 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.Workflow.IWorkflowEvents import IWorkflowActionBegunEvent
+        from Zope.App.Workflow.WorkflowEvents import WorkflowActionBegunEvent
+        from Interface import verify
+        
+        verify( IWorkflowActionBegunEvent, WorkflowActionBegunEvent )
+
+    def _getEventClass( self ):
+        from Zope.App.Workflow.WorkflowEvents import WorkflowActionBegunEvent
+        return WorkflowActionBegunEvent
 
 
-class WorkflowActionSuspendedTests( unittest.TestCase ):
+class WorkflowActionSuspendedTests( unittest.TestCase, WorkflowActionTestsBase ):
 
     def testInterface(self):
         from Zope.App.Workflow.IWorkflowEvents import IWorkflowEvent
@@ -35,8 +71,13 @@
         verify( IWorkflowEvent, WorkflowActionSuspendedEvent )
         verify( IWorkflowActionSuspendedEvent, WorkflowActionSuspendedEvent )
 
+    def _getEventClass( self ):
+        from Zope.App.Workflow.WorkflowEvents \
+            import WorkflowActionSuspendedEvent
+        return WorkflowActionSuspendedEvent
 
-class WorkflowActionCompletedEvent(unittest.TestCase):
+
+class WorkflowActionCompletedEvent(unittest.TestCase, WorkflowActionTestsBase):
 
     def testInterface(self):
         from Zope.App.Workflow.IWorkflowEvents import IWorkflowEvent
@@ -49,25 +90,54 @@
         verify(IWorkflowEvent, WorkflowActionCompletedEvent)
         verify(IWorkflowActionCompletedEvent, WorkflowActionCompletedEvent)
 
+    def _getEventClass( self ):
+        from Zope.App.Workflow.WorkflowEvents \
+            import WorkflowActionCompletedEvent
+        return WorkflowActionCompletedEvent
 
-class WorkflowActionBegunEventTest( unittest.TestCase ):
 
-    def testInterface( self ):
-        from Zope.App.Workflow.IWorkflowEvents import IWorkflowActionBegunEvent
-        from Zope.App.Workflow.WorkflowEvents import WorkflowActionBegunEvent
+class WorkflowActionTerminatedEvent(unittest.TestCase, WorkflowActionTestsBase):
+
+    def testInterface(self):
+        from Zope.App.Workflow.IWorkflowEvents import IWorkflowEvent
+        from Zope.App.Workflow.IWorkflowEvents \
+            import IWorkflowActionTerminatedEvent
+        from Zope.App.Workflow.WorkflowEvents \
+            import WorkflowActionTerminatedEvent
         from Interface import verify
-        
-        verify( IWorkflowActionBegunEvent, WorkflowActionBegunEvent )
 
+        verify(IWorkflowEvent, WorkflowActionTerminatedEvent)
+        verify(IWorkflowActionTerminatedEvent, WorkflowActionTerminatedEvent)
 
-class WorkflowActionAssignedEventTest( unittest.TestCase ):
+    def _getEventClass( self ):
+        from Zope.App.Workflow.WorkflowEvents import WorkflowActionTerminatedEvent
+        return WorkflowActionTerminatedEvent
 
-    def testInterface( self ):
-        from Zope.App.Workflow.IWorkflowEvents import IWorkflowActionAssignedEvent
-        from Zope.App.Workflow.WorkflowEvents import WorkflowActionAssignedEvent
+
+class WorkflowActionExceptionEvent(unittest.TestCase, WorkflowActionTestsBase):
+
+    def testInterface(self):
+        from Zope.App.Workflow.IWorkflowEvents import IWorkflowEvent
+        from Zope.App.Workflow.IWorkflowEvents \
+            import IWorkflowActionExceptionEvent
+        from Zope.App.Workflow.WorkflowEvents \
+            import WorkflowActionExceptionEvent
         from Interface import verify
-        
-        verify( IWorkflowActionAssignedEvent, WorkflowActionAssignedEvent )
+
+        verify(IWorkflowEvent, WorkflowActionExceptionEvent)
+        verify(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
+
+
 
 
 if __name__ == '__main__':