Back to index

plone3  3.1.7
test_DefaultWorkflow.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ Unit tests for DefaultWorkflow module.
00014 
00015 $Id: test_DefaultWorkflow.py 77186 2007-06-28 19:06:19Z yuppie $
00016 """
00017 
00018 import unittest
00019 import Testing
00020 
00021 from Products.CMFCore.tests.base.dummy import DummyContent
00022 from Products.CMFCore.tests.base.dummy import DummySite
00023 from Products.CMFCore.tests.base.dummy import DummyTool
00024 from Products.CMFCore.tests.base.dummy import DummyUserFolder
00025 from Products.CMFCore.WorkflowTool import WorkflowTool
00026 
00027 
00028 class DefaultWorkflowDefinitionTests(unittest.TestCase):
00029 
00030     def setUp(self):
00031         from Products.CMFDefault.DefaultWorkflow \
00032                 import DefaultWorkflowDefinition
00033         self.site = DummySite('site')
00034         self.site._setObject('portal_types', DummyTool())
00035         self.site._setObject('portal_workflow', WorkflowTool())
00036         self.site._setObject('portal_membership', DummyTool())
00037         self.site._setObject('acl_users', DummyUserFolder())
00038 
00039         wftool = self.site.portal_workflow
00040         wftool._setObject('wf', DefaultWorkflowDefinition('wf'))
00041         wftool.setDefaultChain('wf')
00042 
00043     def test_z2interfaces(self):
00044         from Interface.Verify import verifyClass
00045         from Products.CMFCore.interfaces.portal_workflow \
00046                 import WorkflowDefinition as IWorkflowDefinition
00047         from Products.CMFDefault.DefaultWorkflow \
00048                 import DefaultWorkflowDefinition
00049 
00050         verifyClass(IWorkflowDefinition, DefaultWorkflowDefinition)
00051 
00052     def test_z3interfaces(self):
00053         from zope.interface.verify import verifyClass
00054         from Products.CMFCore.interfaces import IWorkflowDefinition
00055         from Products.CMFDefault.DefaultWorkflow \
00056                 import DefaultWorkflowDefinition
00057 
00058         verifyClass(IWorkflowDefinition, DefaultWorkflowDefinition)
00059 
00060     def _getDummyWorkflow(self):
00061         wftool = self.site.portal_workflow
00062         return wftool.wf
00063 
00064     def test_isActionSupported(self):
00065 
00066         wf = self._getDummyWorkflow()
00067         dummy = self.site._setObject('dummy', DummyContent())
00068 
00069         for action in ('submit', 'retract', 'publish', 'reject',):
00070             self.assert_(wf.isActionSupported(dummy, action))
00071 
00072     def test_isActionSupported_with_keywargs(self):
00073 
00074         wf = self._getDummyWorkflow()
00075         dummy = self.site._setObject('dummy', DummyContent())
00076 
00077         for action in ('submit', 'retract', 'publish', 'reject',):
00078             self.assert_(wf.isActionSupported(dummy, action,
00079                                               arg1=1, arg2=2))
00080 
00081     # XXX more tests...
00082 
00083 
00084 def test_suite():
00085     return unittest.TestSuite((
00086         unittest.makeSuite(DefaultWorkflowDefinitionTests),
00087         ))
00088 
00089 if __name__ == '__main__':
00090     unittest.main(defaultTest='test_suite')