Commit 61b8b27d authored by wenjie.zheng's avatar wenjie.zheng

erp5_workflow: testWorkflow5Method add erp5workflow state accessor test and...

erp5_workflow: testWorkflow5Method add erp5workflow state accessor test and DCworkflow state accessor test. Test the conflict between 2 types of accessor and the funtionality of workflow methods, also the translations of the state.
parent 755f7616
...@@ -5,6 +5,7 @@ class TestERP5Workflow(ERP5TypeTestCase): ...@@ -5,6 +5,7 @@ class TestERP5Workflow(ERP5TypeTestCase):
""" """
Tests ERP5 Workflow. Tests ERP5 Workflow.
""" """
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
"""Returns list of BT to be installed.""" """Returns list of BT to be installed."""
return ('erp5_workflow',) return ('erp5_workflow',)
...@@ -14,7 +15,7 @@ class TestERP5Workflow(ERP5TypeTestCase): ...@@ -14,7 +15,7 @@ class TestERP5Workflow(ERP5TypeTestCase):
self.workflow_module = self.portal.workflow_module self.workflow_module = self.portal.workflow_module
self.login() # as Manager self.login() # as Manager
def test_Erp5TransitionMethod(self): def test01_Erp5AccessorMethod(self):
"""Generate Transition Methods and test these methods.""" """Generate Transition Methods and test these methods."""
# Create base category as the intermidiate # Create base category as the intermidiate
self.portal.portal_categories.newContent('category_state') self.portal.portal_categories.newContent('category_state')
...@@ -22,9 +23,9 @@ class TestERP5Workflow(ERP5TypeTestCase): ...@@ -22,9 +23,9 @@ class TestERP5Workflow(ERP5TypeTestCase):
# Create a workflow # Create a workflow
new_workflow = self.workflow_module.newContent(portal_type='Workflow', new_workflow = self.workflow_module.newContent(portal_type='Workflow',
id='new_workflow') id='new_workflow')
s1 = new_workflow.newContent(portal_type='State',title='draft') s1 = new_workflow.newContent(portal_type='State',title='Draft', id='draft')
s2 = new_workflow.newContent(portal_type='State',title='validated') s2 = new_workflow.newContent(portal_type='State',title='Validated', id='validated')
s3 = new_workflow.newContent(portal_type='State',title='couscous') s3 = new_workflow.newContent(portal_type='State',title='Couscous', id='Couscous')
t1 = new_workflow.newContent( t1 = new_workflow.newContent(
portal_type='Transition', portal_type='Transition',
...@@ -59,8 +60,8 @@ class TestERP5Workflow(ERP5TypeTestCase): ...@@ -59,8 +60,8 @@ class TestERP5Workflow(ERP5TypeTestCase):
type_base_category_list=(['category_state',]) type_base_category_list=(['category_state',])
) )
type_object.erp5workflow_list = ('new_workflow',) type_object.edit(type_erp5workflow_list=('new_workflow',))
#type_object.erp5workflow_list = ('new_workflow',)
# create a module # create a module
self.portal.portal_types.newContent( self.portal.portal_types.newContent(
'Module Type', 'Base Type', 'Module Type', 'Base Type',
...@@ -76,21 +77,35 @@ class TestERP5Workflow(ERP5TypeTestCase): ...@@ -76,21 +77,35 @@ class TestERP5Workflow(ERP5TypeTestCase):
self.assertTrue(new_object is not None) self.assertTrue(new_object is not None)
self.assertEqual(new_object.getPortalType(), 'Object Type') self.assertEqual(new_object.getPortalType(), 'Object Type')
self.assertEqual(new_object.getCategoryStateTitle(), 'draft') self.assertEqual(new_object.getCategoryState(), 'draft')
self.assertEqual(new_object.getCategoryStateTitle(), 'Draft')
### execute transition ### execute transition
t1.execute(new_object) t1.execute(new_object)
self.assertEqual(new_object.getCategoryStateTitle(), 'validated') self.assertEqual(new_object.getCategoryStateTitle(), 'Validated')
self.portal.Localizer._default_language = 'fr'
### call accessor ### call accessor
new_object.transition2() new_object.transition2()
self.assertEqual(new_object.getCategoryStateTitle(), 'draft') self.assertEqual(new_object.getCategoryStateTitle(), 'Draft')
self.assertEqual(new_object.getTranslatedCategoryStateTitle(), 'Brouillon')
new_object.transition1() new_object.transition1()
self.assertEqual(new_object.getCategoryStateTitle(), 'validated') self.assertEqual(new_object.getCategoryStateTitle(), 'Validated')
new_object.setToCouscousPlease() new_object.setToCouscousPlease()
self.assertEqual(new_object.getCategoryStateTitle(), 'couscous') self.assertEqual(new_object.getCategoryStateTitle(), 'Couscous')
organisationX = self.portal.organisation_module.newContent(
portal_type='Organisation',
id='orgnisation_x')
self.portal.Localizer._default_language = 'fr'
self.assertEqual(organisationX.getValidationStateTitle(), 'Draft')
self.assertEqual(organisationX.getTranslatedValidationStateTitle(), 'Brouillon')
organisationX.validate()
self.assertEqual(organisationX.getValidationStateTitle(), 'Validated')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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