Get testBusinessTemplate to work on CMF 2.2. Add a fake manage_addWorkflow...

Get testBusinessTemplate to work on CMF 2.2. Add a fake manage_addWorkflow method to portal_workflow, and switch to adding erp5_workflows instead of dc_workflows, which are much harder to add programatically on CMF 2.2

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30750 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8a90624c
...@@ -44,6 +44,22 @@ from Products.CMFCore.tests.base.testcase import LogInterceptor ...@@ -44,6 +44,22 @@ from Products.CMFCore.tests.base.testcase import LogInterceptor
import shutil import shutil
import os import os
from MethodObject import Method
from Persistence import Persistent
class Fake_manage_addWorkflow(Method, Persistent):
isFake = True # flag to allow removal of this method.
def __call__(self, context, workflow_type, workflow_id):
workflow_factory_id, _workflow_type_title = workflow_type.split(' ', 1)
dispatcher = context.manage_addProduct['ERP5Type']
factory = getattr(dispatcher,
'addWorkflow_' + workflow_factory_id)
return factory(workflow_id)
WORKFLOW_TYPE = 'erp5_workflow (ERP5-style empty workflow)'
class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
""" """
Test these operations: Test these operations:
...@@ -88,10 +104,23 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -88,10 +104,23 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
'any' in content_type_registry.predicate_ids): 'any' in content_type_registry.predicate_ids):
content_type_registry.removePredicate('any') content_type_registry.removePredicate('any')
transaction.commit() transaction.commit()
pw = self.getWorkflowTool()
if getattr(pw, 'manage_addWorkflow', None) is None:
# CMF 2.2 no longer has manage_addWorkflow, and workflows should be added
# using manage_addProduct['ERP5Type'].manage_addWorkflow_<factory-id>,
# but this doesn't work on CMF 1.5
# BACK: stop using this hack when we drop Zope 2.8, CMF 2.2
pw.manage_addWorkflow = Fake_manage_addWorkflow()
def beforeTearDown(self): def beforeTearDown(self):
"""Remove objects created tests.""" """Remove objects created tests."""
pw = self.getWorkflowTool() pw = self.getWorkflowTool()
if getattr(aq_base(pw.manage_addWorkflow),
'isFake', False):
# remove fake method which was added to make tests compatible with CMF 2.2
# BACK: remove this hack when we've abandoned Zope 2.8
del pw.manage_addWorkflow
cbt = pw._chains_by_type cbt = pw._chains_by_type
props = {} props = {}
if cbt is not None: if cbt is not None:
...@@ -1099,7 +1128,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -1099,7 +1128,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
Create a workflow Create a workflow
""" """
pw = self.getWorkflowTool() pw = self.getWorkflowTool()
pw.manage_addWorkflow('dc_workflow (Web-configurable workflow)', 'geek_workflow') pw.manage_addWorkflow(WORKFLOW_TYPE, 'geek_workflow')
workflow = pw._getOb('geek_workflow', None) workflow = pw._getOb('geek_workflow', None)
self.failUnless(workflow is not None) self.failUnless(workflow is not None)
sequence.edit(workflow_id=workflow.getId()) sequence.edit(workflow_id=workflow.getId())
...@@ -4763,8 +4792,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -4763,8 +4792,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
Create a custom workflow Create a custom workflow
""" """
pw = self.getWorkflowTool() pw = self.getWorkflowTool()
pw.manage_addWorkflow('dc_workflow (Web-configurable workflow)', pw.manage_addWorkflow(WORKFLOW_TYPE, 'custom_geek_workflow')
'custom_geek_workflow')
workflow = pw._getOb('custom_geek_workflow', None) workflow = pw._getOb('custom_geek_workflow', None)
self.failUnless(workflow is not None) self.failUnless(workflow is not None)
sequence.edit(workflow_id=workflow.getId()) sequence.edit(workflow_id=workflow.getId())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment