Commit 84c8f0f4 authored by wenjie.zheng's avatar wenjie.zheng

testERP5Type.py: add ERP5Workflow compability; Base.py: fix unsupportWorkflowMethod error.

parent 9e965250
......@@ -182,13 +182,13 @@ class ERP5WorkflowMethod(Method):
for wf_id, transition_list in candidate_transition_item_list:
valid_list = []
for transition_id in transition_list:
LOG('zwj: Executing %s in %s' %(transition_id, wf_id), WARNING, "lol")
LOG('zwj: Executing %s in %s' %(transition_id, wf_id), WARNING, " in Base.py.")
if wf5_module._getOb(wf_id).isERP5WorkflowMethodSupported(instance, wf5_module._getOb(wf_id)._getOb(transition_id)):
valid_list.append(transition_id)
once_transition_key = once_transition_dict.get((wf_id, transition_id))
transactional_variable[once_transition_key] = 1
else:
raise UnsupportedWorkflowMethod("The Transition is not supported by current state.")
raise UnsupportedWorkflowMethod(instance, wf_id, transition_id)
if valid_list:
valid_transition_item_list.append((wf_id, valid_list))
......@@ -3379,6 +3379,8 @@ class Base( CopyContainer,
There's no check that the document is actually chained to the workflow,
it's caller responsability to perform this check.
### zwj: where this function is used?
"""
workflow = self.portal_workflow.getWorkflowById(wf_id)
......
......@@ -29,7 +29,7 @@
import cPickle
import unittest
import sys
import pdb
import transaction
from random import randint
from Acquisition import aq_base
......@@ -975,17 +975,24 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
"""Tests for workflow state. assumes that validation state is chained to
the Person portal type and that this workflow has 'validation_state' as
state_variable.
zwj: 28-1-2015 add ERP5Workflow compability.
"""
self.portal.Localizer = DummyLocalizer()
message_catalog = self.portal.Localizer.erp5_ui
person = self.getPersonModule().newContent(id='1', portal_type='Person')
wf = self.getWorkflowTool().validation_workflow
# those are assumptions for this test.
self.assertTrue(wf.getId() in
if not person.getTypeInfo().getTypeERP5WorkflowList():
wf = self.getWorkflowTool().validation_workflow
self.assertTrue(wf.getId() in
self.getWorkflowTool().getChainFor('Person'))
self.assertEqual('validation_state', wf.variables.getStateVar())
initial_state = wf.states[wf.initial_state]
other_state = wf.states['validated']
self.assertEqual('validation_state', wf.variables.getStateVar())
initial_state = wf.states[wf.initial_state]
other_state = wf.states['validated']
else:
wf = self.getPortalObject().getDefaultModule('Workflow')._getOb('erp5_validation_workflow')
initial_state = wf.getSourceValue()
other_state = wf._getOb('validated')
self.assertTrue(hasattr(person, 'getValidationState'))
self.assertTrue(hasattr(person, 'getValidationStateTitle'))
......@@ -1829,13 +1836,16 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# Create a new temporary person object.
from Products.ERP5Type.Document import newTempPerson
o = newTempPerson(portal, 'temp_person_1')
#pdb.set_trace()
self.assertTrue(o.isTempObject())
self.assertEqual(o.getOriginalDocument(), None)
# This should generate a workflow method.
self.assertEqual(o.getValidationState(), 'draft')
o.validate()
self.assertEqual(o.getValidationState(), 'validated')
# ERP5 workflow doesn't support this step, pass,
if not o.getTypeInfo().getTypeERP5WorkflowList():
self.assertEqual(o.getValidationState(), 'draft')
o.validate()
self.assertEqual(o.getValidationState(), 'validated')
# Create a new persistent person object.
person_module = portal.person_module
......@@ -1873,9 +1883,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertTrue(o.isTempObject())
# This should call methods generated for the persistent object.
self.assertEqual(o.getValidationState(), 'draft')
o.validate()
self.assertEqual(o.getValidationState(), 'validated')
### zwj: ERP5Workflow doesn't support, pass
if not o.getTypeInfo().getTypeERP5WorkflowList():
self.assertEqual(o.getValidationState(), 'draft')
o.validate()
self.assertEqual(o.getValidationState(), 'validated')
def test_26_hasAccessors(self):
"""Test 'has' Accessor.
......
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