Commit 74104d77 authored by Julien Muchembled's avatar Julien Muchembled

Fix TestTaskReporting

- Make start/stop date calculation by Business Process optional.
- Run TestTaskReporting with both legacy and new simulations.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41352 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d3574742
......@@ -10,6 +10,7 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>items</string>
<string>title</string>
</list>
......@@ -82,6 +83,11 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>Compute expected start and stop dates according to the specified Trade Phase.\n
If unset, no calculation is done (i.e. dates are taken from the movement generated by the rule).</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_end_of</string> </value>
......
1087
\ No newline at end of file
1088
\ No newline at end of file
......@@ -187,8 +187,7 @@ class BusinessProcess(Path, XMLObject):
raise ValueError('explanation must not be a Root Applied Rule')
trade_date = trade_model_path.getTradeDate()
if not trade_date:
raise ValueError('a trade_date must be defined on every Trade Model Path')
assert trade_date, 'a trade_date must be defined on the Trade Model Path'
reference_date_method_id = trade_model_path.getReferenceDateMethodId()
if not reference_date_method_id:
......@@ -797,14 +796,15 @@ class BusinessProcess(Path, XMLObject):
# global.
if explanation.getPortalType() == 'Applied Rule':
if explanation.getParentValue().getPortalType() != "Simulation Tool":
# It only makes sens to search for start and start date for
# applied rules which are not root applied rules.
# XXX-JPS could be extended with a rule property instead
# of supports only in root applied rule case
start_date, stop_date = self.getExpectedTradeModelPathStartAndStopDate(
explanation, trade_model_path, delay_mode=delay_mode)
property_dict['start_date'] = start_date
property_dict['stop_date'] = stop_date
# It only makes sense to search for start and stop dates for
# applied rules which are not root applied rules.
# Date calculation by Business Process can be also disabled by
# leaving 'trade_phase' unset (XXX: a separate boolean property,
# on the TMP or the rule, may be better).
if trade_model_path.getTradeDate():
property_dict['start_date'], property_dict['stop_date'] = \
self.getExpectedTradeModelPathStartAndStopDate(
explanation, trade_model_path, delay_mode=delay_mode)
else:
raise TypeError("Explanation must be an Applied Rule in expand process") # Nothing to do
return property_dict
......
......@@ -31,7 +31,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase
from Products.ERP5Type.tests.utils import reindex
import transaction
from DateTime import DateTime
from Products.ERP5.tests.utils import newSimulationExpectedFailure
class TestTaskReporting(ERP5ReportTestCase):
"""Test Task Reporting
......@@ -47,23 +46,44 @@ class TestTaskReporting(ERP5ReportTestCase):
@reindex
def _makeOneTask(self, simulation_state='planned', **kw):
"""Create a task, support many options"""
task_module = self.getPortalObject().task_module
task = task_module.newContent(portal_type='Task', **kw)
task = self.portal.task_module.newContent(portal_type='Task',
specialise=self.business_process)
task._edit(**kw)
if simulation_state == 'planned':
task.plan()
if simulation_state == 'confirmed':
task.confirm()
def createBusinessProcess(self):
module = self.portal.business_process_module
id = self.__class__.__name__
try:
business_process = module[id]
except KeyError:
default = module.erp5_default_business_process
business_process = module.newContent(id, default.getPortalType(),
specialise_value=default)
delivery_path, = default.getTradeModelPathValueList(
trade_phase='default/delivery')
# We don't set any trade_date here, so that start and stop dates
# are copied from Tasks to Task Reports.
business_process.newContent(portal_type=delivery_path.getPortalType(),
reference=delivery_path.getReference(),
trade_phase=delivery_path.getTradePhase())
return business_process.getRelativeUrl()
def afterSetUp(self):
"""Setup the fixture.
"""
self.portal = self.getPortal()
for rule_id in ['default_order_rule', 'default_delivery_rule']:
rule = getattr(self.portal.portal_rules, rule_id)
if rule.getValidationState() == 'draft':
for rule_id in ('default_order_rule',
'default_delivery_rule',
'default_delivering_rule'):
rule = self.getRule(reference=rule_id)
if rule.getValidationState() != 'validated':
rule.validate()
self.business_process = self.createBusinessProcess()
# create organisations
if not self.portal.organisation_module.has_key('Organisation_1'):
org = self.portal.organisation_module.newContent(
......@@ -153,19 +173,16 @@ class TestTaskReporting(ERP5ReportTestCase):
"""Remove all documents.
"""
transaction.abort()
portal = self.getPortal()
portal = self.portal
portal.task_module.manage_delObjects(
list(portal.task_module.objectIds()))
portal.task_report_module.manage_delObjects(
list(portal.task_report_module.objectIds()))
portal.portal_simulation.manage_delObjects(
list(portal.portal_simulation.objectIds()))
transaction.commit()
self.tic()
@newSimulationExpectedFailure
def testProjectMontlyReport(self):
"""
Check monthly report available on project
......
......@@ -28,12 +28,15 @@
from Products.ERP5Legacy.tests import Legacy_getBusinessTemplateList
test_suite_list = []
from Products.ERP5.tests.testProject import *
test_suite_list.append(test_suite)
from Products.ERP5.tests.testTask import *
test_suite_list.append(test_suite)
from Products.ERP5.tests.testTaskReporting import *
test_suite_list.append(test_suite)
from Products.ERP5.tests.testTaskReportDivergence import *
test_suite_list.append(test_suite)
# testProject breaks testTaskReporting so we run it after
from Products.ERP5.tests.testProject import *
test_suite_list.append(test_suite)
# WARNING: TestProject is tested with rules using 'order' category
TestProject.rule_id_list = 'default_order_rule', 'default_delivery_rule'
......@@ -43,6 +46,9 @@ Legacy_getBusinessTemplateList(TestProject)
TestTaskMixin.business_process = None
Legacy_getBusinessTemplateList(TestTaskMixin)
TestTaskReporting.createBusinessProcess = lambda self: None
Legacy_getBusinessTemplateList(TestTaskReporting)
def test_suite():
suite = test_suite_list[0]()
for test_suite in test_suite_list[1:]:
......
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