Commit 42ed3c49 authored by Nicolas Dumazet's avatar Nicolas Dumazet

testERP5Type was messing heavily with workflow chains and relying on

transaction aborts to restore them. That's hackish, and fails as soon as
an "innocent" hand comes in and adds a commit in a test.

* save and restore workflow chain for Person at beginning and start of test
* use setChainForPortalTypes instead of manage_changeWorkflows: the
  first call alters the chain for one portal type, whereas the second affects
  ALL portal types, effectively removing all chains from all portal types not
  passed along in props=. It meant that after each manage_changeWorkflows the
  test was running virtually without any workflow but those of Person, causing
  "fake" failures in other, correct, tests.

This eventually fixes the last failures of testERP5Type


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43101 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 376ed4ef
...@@ -131,6 +131,9 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -131,6 +131,9 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.getTypesTool().getTypeInfo('Person').filter_content_types = 0 self.getTypesTool().getTypeInfo('Person').filter_content_types = 0
transaction.commit() transaction.commit()
# save workflow chain for Person type
self.person_chain = self.getWorkflowTool().getChainFor('Person')
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort() transaction.abort()
for module in [ self.getPersonModule(), for module in [ self.getPersonModule(),
...@@ -143,6 +146,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -143,6 +146,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.getTypesTool().getTypeInfo('Person').acquire_local_roles = self.person_acquire_local_roles self.getTypesTool().getTypeInfo('Person').acquire_local_roles = self.person_acquire_local_roles
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
# restore workflows for other tests
self.getWorkflowTool().setChainForPortalTypes(
['Person'], self.person_chain)
super(TestERP5Type, self).beforeTearDown() super(TestERP5Type, self).beforeTearDown()
def loginWithNoRole(self): def loginWithNoRole(self):
...@@ -2436,25 +2443,21 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2436,25 +2443,21 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_aq_reset_on_workflow_chain_change(self): def test_aq_reset_on_workflow_chain_change(self):
doc = self.portal.person_module.newContent(portal_type='Person') doc = self.portal.person_module.newContent(portal_type='Person')
ti = self.getTypesTool()['Person']
self.assertFalse(hasattr(doc, 'getCausalityState')) self.assertFalse(hasattr(doc, 'getCausalityState'))
# chain the portal type with a workflow that has 'causality_state' as # chain the portal type with a workflow that has 'causality_state' as
# state variable name, this should regenerate the getCausalityState # state variable name, this should regenerate the getCausalityState
# accessor. This test might have to be updated whenever # accessor. This test might have to be updated whenever
# delivery_causality_workflow changes. # delivery_causality_workflow changes.
self.portal.portal_workflow.manage_changeWorkflows( self.getWorkflowTool().setChainForPortalTypes(
default_chain='', ['Person'], ('delivery_causality_workflow'))
props=dict(chain_Person='delivery_causality_workflow'))
transaction.commit() transaction.commit()
self.assertTrue(hasattr(doc, 'getCausalityState')) self.assertTrue(hasattr(doc, 'getCausalityState'))
def test_aq_reset_on_workflow_method_change(self): def test_aq_reset_on_workflow_method_change(self):
doc = self.portal.person_module.newContent(portal_type='Person') doc = self.portal.person_module.newContent(portal_type='Person')
ti = self.getTypesTool()['Person'] self.getWorkflowTool().setChainForPortalTypes(
self.portal.portal_workflow.manage_changeWorkflows( ['Person'], ('delivery_causality_workflow'))
default_chain='',
props=dict(chain_Person='delivery_causality_workflow'))
transaction.commit() transaction.commit()
self.assertTrue(hasattr(doc, 'diverge')) self.assertTrue(hasattr(doc, 'diverge'))
...@@ -2475,10 +2478,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2475,10 +2478,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_aq_reset_on_workflow_state_variable_change(self): def test_aq_reset_on_workflow_state_variable_change(self):
doc = self.portal.person_module.newContent(portal_type='Person') doc = self.portal.person_module.newContent(portal_type='Person')
ti = self.getTypesTool()['Person'] self.getWorkflowTool().setChainForPortalTypes(
self.portal.portal_workflow.manage_changeWorkflows( ['Person'], ('delivery_causality_workflow'))
default_chain='',
props=dict(chain_Person='delivery_causality_workflow'))
transaction.commit() transaction.commit()
self.assertTrue(hasattr(doc, 'getCausalityState')) self.assertTrue(hasattr(doc, 'getCausalityState'))
......
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