[CMF-checkins] CVS: CMF/DCWorkflow/tests - test_DCWorkflow.py:1.1 test_all.py:1.6

Yvo Schubbe schubbe at web.de
Fri Jan 2 13:07:32 EST 2004


Update of /cvs-repository/CMF/DCWorkflow/tests
In directory cvs.zope.org:/tmp/cvs-serv1244/DCWorkflow/tests

Modified Files:
	test_all.py 
Added Files:
	test_DCWorkflow.py 
Log Message:
- added __implements__ to DCWorkflow
- added 'comment' as explicit kw of doActionFor() to make verifyClass happy
- added 2 basic DCWorkflow tests


=== Added File CMF/DCWorkflow/tests/test_DCWorkflow.py ===
from unittest import TestCase, TestSuite, makeSuite, main

import Testing
import Zope
try:
    Zope.startup()
except AttributeError:
    # for Zope versions before 2.6.1
    pass
try:
    from Interface.Verify import verifyClass
except ImportError:
    # for Zope versions before 2.6.0
    from Interface import verify_class_implementation as verifyClass

from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.WorkflowTool import addWorkflowFactory
from Products.CMFCore.WorkflowTool import WorkflowTool
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition


class DCWorkflowDefinitionTests(TestCase):

    def setUp( self ):
        self.site = DummySite('site')
        self.site._setObject( 'portal_types', DummyTool() )
        self.site._setObject( 'portal_workflow', WorkflowTool() )
        addWorkflowFactory(DCWorkflowDefinition)

    def test_doActionFor(self):
        wftool = self.site.portal_workflow
        wftool.manage_addWorkflow('Workflow (DC Workflow Definition)', 'wf')
        wftool.setDefaultChain('wf')

        wf = wftool.wf
        wf.states.addState('private')
        sdef = wf.states['private']
        sdef.setProperties( transitions=('publish',) )
        wf.states.addState('published')
        wf.states.setInitialState('private')
        wf.transitions.addTransition('publish')
        tdef = wf.transitions['publish']
        tdef.setProperties(title='', new_state_id='published', actbox_name='')
        wf.variables.addVariable('comments')
        vdef = wf.variables['comments']
        vdef.setProperties(description='',
                 default_expr="python:state_change.kwargs.get('comment', '')",
                 for_status=1, update_always=1)

        dummy = self.site._setObject( 'dummy', DummyContent() )
        wftool.notifyCreated(dummy)
        self.assertEqual( wf._getStatusOf(dummy),
                          {'state': 'private', 'comments': ''} )
        wf.doActionFor(dummy, 'publish', comment='foo' )
        self.assertEqual( wf._getStatusOf(dummy),
                          {'state': 'published', 'comments': 'foo'} )

    def test_interface(self):
        from Products.CMFCore.interfaces.portal_workflow \
                import WorkflowDefinition as IWorkflowDefinition

        verifyClass(IWorkflowDefinition, DCWorkflowDefinition)


def test_suite():
    return TestSuite((
        makeSuite(DCWorkflowDefinitionTests),
        ))

if __name__ == '__main__':
    main(defaultTest='test_suite')


=== CMF/DCWorkflow/tests/test_all.py 1.5 => 1.6 ===
--- CMF/DCWorkflow/tests/test_all.py:1.5	Wed Jun 12 16:30:13 2002
+++ CMF/DCWorkflow/tests/test_all.py	Fri Jan  2 13:07:31 2004
@@ -1,9 +1,19 @@
-"""Currently all stub, no substance."""
-import unittest
+from unittest import main
+
+import Testing
+import Zope
+try:
+    Zope.startup()
+except AttributeError:
+    # for Zope versions before 2.6.1
+    pass
+
 from Products.CMFCore.tests.base.utils import build_test_suite
 
 def test_suite():
-    return unittest.TestSuite()
+    return build_test_suite('Products.DCWorkflow.tests',[
+        'test_DCWorkflow',
+        ])
 
 if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+    main(defaultTest='test_suite')




More information about the CMF-checkins mailing list