Commit 0e2ab30c authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_forge: add create task from bug relate test

parent 546b7bcc
......@@ -2,6 +2,8 @@ task = context.getFollowUpRelatedValue(portal_type='Task')
if task:
task_report = task.getCausalityRelatedValue(portal_type='Task Report')
if task_report is None or task_report.getSimulationState() not in ('delivered'):
if batch:
return task
message = context.Base_translateString("A task is already created for this bug")
return task.Base_redirect('view', keep_items={'portal_status_message': message})
......@@ -18,5 +20,7 @@ task = context.task_module.newContent(
source_project = context.getSourceProject(), #project
follow_up_value = context
)
if batch:
return task
message = context.Base_translateString("A new task is created for this bug")
return task.Base_redirect('view', keep_items={'portal_status_message': message})
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>start_date, stop_date, **kw</string> </value>
<value> <string>start_date, stop_date, batch=0, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -611,6 +611,48 @@ class TestBug(ERP5TypeTestCase):
self.commit()
self.assertGreater(bug.getModificationDate(), bug_modification_date)
def test_createTaskFromBug(self):
self.loginByUserName('mame')
bug_portal_type = 'Bug'
module = self.portal.getDefaultModule(portal_type=bug_portal_type)
bug = module.newContent(portal_type=bug_portal_type)
bug_line = bug.newContent(portal_type='Bug Line')
bug_line.Base_createCloneDocument(batch_mode=1)
self.workflow_tool.doActionFor(bug, 'confirm_action', send_event=1)
self.assertEqual(bug.getSimulationState(), 'confirmed')
self.tic()
task = bug.Bug_newTask(start_date=DateTime(), stop_date=DateTime(), batch=1)
self.assertTrue(task is not None)
self.assertEqual(task.getFollowUpValue(), bug)
self.tic()
# can't create another one if previous is not finished
self.assertEqual(task, bug.Bug_newTask(start_date=DateTime(), stop_date=DateTime(), batch=1))
# XXXX add manually related task report
task_report = self.portal.task_report_module.newContent(portal_type='Task Report')
task_report.edit(
causality_value = task)
self.tic()
task_report.confirm()
task_report.start()
task_report.stop()
self.workflow_tool.doActionFor(task_report, 'deliver_action', close_bug=0)
self.tic()
self.assertEqual(bug.getSimulationState(), 'confirmed')
another_task = bug.Bug_newTask(start_date=DateTime(), stop_date=DateTime(), batch=1)
self.assertTrue(another_task is not None)
self.assertTrue(another_task != task)
task_report = self.portal.task_report_module.newContent(portal_type='Task Report')
task_report.edit(
causality_value = task)
self.tic()
task_report.confirm()
task_report.start()
task_report.stop()
self.workflow_tool.doActionFor(task_report, 'deliver_action', close_bug=1)
self.tic()
self.assertEqual(bug.getSimulationState(), 'stopped')
def test_suite():
suite = unittest.TestSuite()
......
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testBug</string> </value>
......@@ -53,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -72,7 +93,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -81,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
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