Commit b78a14da authored by Julien Muchembled's avatar Julien Muchembled

testTradeModelLine: do not validate old rules and create default trade model path

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@37447 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dfec1c6c
...@@ -46,6 +46,7 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -46,6 +46,7 @@ class TestBPMMixin(ERP5TypeTestCase):
business_process_portal_type = 'Business Process' business_process_portal_type = 'Business Process'
business_link_portal_type = 'Business Link' business_link_portal_type = 'Business Link'
trade_model_path_portal_type = 'Trade Model Path'
normal_resource_use_category_list = ['normal'] normal_resource_use_category_list = ['normal']
invoicing_resource_use_category_list = ['discount', 'tax'] invoicing_resource_use_category_list = ['discount', 'tax']
...@@ -90,6 +91,12 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -90,6 +91,12 @@ class TestBPMMixin(ERP5TypeTestCase):
portal_type=self.business_link_portal_type, **kw) portal_type=self.business_link_portal_type, **kw)
return business_link return business_link
def createTradeModelPath(self, business_process=None, **kw):
if business_process is None:
business_process = self.createBusinessProcess()
return business_process.newContent(
portal_type=self.trade_model_path_portal_type, **kw)
def createMovement(self): def createMovement(self):
# returns a movement for testing # returns a movement for testing
applied_rule = self.portal.portal_simulation.newContent( applied_rule = self.portal.portal_simulation.newContent(
...@@ -195,7 +202,12 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -195,7 +202,12 @@ class TestBPMMixin(ERP5TypeTestCase):
itr.validate() itr.validate()
def afterSetUp(self): def afterSetUp(self):
self.validateRules() rule_tool = self.getRuleTool()
for rule in rule_tool.contentValues(
portal_type=rule_tool.getPortalRuleTypeList()):
if rule.getId().startswith('new_') and \
rule.getValidationState() != 'validated':
rule.validate()
self.createCategories() self.createCategories()
self.createInvoiceTransactionRule() self.createInvoiceTransactionRule()
self.stepTic() self.stepTic()
......
...@@ -37,6 +37,7 @@ from DateTime import DateTime ...@@ -37,6 +37,7 @@ from DateTime import DateTime
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestTradeModelLineMixin(TestBPMMixin): class TestTradeModelLineMixin(TestBPMMixin):
"""Provides methods to implementations sharing similar logic to Trade Model Lines""" """Provides methods to implementations sharing similar logic to Trade Model Lines"""
# Constants and variables shared by tests # Constants and variables shared by tests
...@@ -48,18 +49,19 @@ class TestTradeModelLineMixin(TestBPMMixin): ...@@ -48,18 +49,19 @@ class TestTradeModelLineMixin(TestBPMMixin):
return module.newContent(portal_type=portal_type, **kw) return module.newContent(portal_type=portal_type, **kw)
# Steps # Steps
def stepCreatePriceCurrency(self, sequence=None, **kw): def stepCreatePriceCurrency(self, sequence=None):
sequence.edit(price_currency = self.createResource('Currency', \ sequence.edit(price_currency = self.createResource('Currency', \
title='Currency', base_unit_quantity=self.base_unit_quantity)) title='Currency', base_unit_quantity=self.base_unit_quantity))
def stepCreateBusinessProcess(self, sequence=None, **kw): def stepCreateBusinessProcess(self, sequence=None):
sequence.edit(business_process=self.createBusinessProcess( sequence.edit(business_process=self.createBusinessProcess(
title=self.id())) title=self.id()))
def stepCreateBusinessLink(self, sequence=None, **kw): def stepCreateBusinessLink(self, sequence):
business_process = sequence.get('business_process') business_process = sequence.get('business_process')
sequence.edit(business_link=self.createBusinessLink(business_process)) sequence.edit(business_link=self.createBusinessLink(business_process))
class TestTradeModelLine(TestTradeModelLineMixin): class TestTradeModelLine(TestTradeModelLineMixin):
quiet = True quiet = True
...@@ -105,6 +107,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -105,6 +107,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing ModifyBusinessLinkTaxing
CreateBusinessLink CreateBusinessLink
ModifyBusinessLinkDiscounting ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
...@@ -195,7 +198,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -195,7 +198,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
portal_type='Trade Model Line', portal_type='Trade Model Line',
**kw) **kw)
def stepModifyBusinessLinkDiscounting(self, sequence=None, **kw): def stepModifyBusinessLinkDiscounting(self, sequence):
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
predecessor = category_tool.trade_state.invoiced predecessor = category_tool.trade_state.invoiced
successor = category_tool.trade_state.taxed successor = category_tool.trade_state.taxed
...@@ -210,7 +213,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -210,7 +213,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
) )
sequence.edit(business_link=None, business_link_discounting=business_link) sequence.edit(business_link=None, business_link_discounting=business_link)
def stepModifyBusinessLinkTaxing(self, sequence=None, **kw): def stepModifyBusinessLinkTaxing(self, sequence):
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
predecessor = category_tool.trade_state.invoiced predecessor = category_tool.trade_state.invoiced
successor = category_tool.trade_state.taxed successor = category_tool.trade_state.taxed
...@@ -225,6 +228,16 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -225,6 +228,16 @@ class TestTradeModelLine(TestTradeModelLineMixin):
) )
sequence.edit(business_link=None, business_link_taxing=business_link) sequence.edit(business_link=None, business_link_taxing=business_link)
def stepCreateTradeModelPath(self, sequence):
trade_phase = self.getCategoryTool().trade_phase
sequence.set('trade_model_path_default', self.createTradeModelPath(
sequence.get('business_process'),
reference='default_path',
int_index=0,
trade_phase_value_list=trade_phase.default.getCategoryChildValueList(),
trade_date_value=trade_phase.default.order,
))
def stepAcceptDecisionQuantityInvoice(self, sequence=None, **kw): def stepAcceptDecisionQuantityInvoice(self, sequence=None, **kw):
invoice = sequence.get('invoice') invoice = sequence.get('invoice')
solver_process_tool = self.portal.portal_solver_processes solver_process_tool = self.portal.portal_solver_processes
...@@ -1451,6 +1464,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -1451,6 +1464,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing ModifyBusinessLinkTaxing
CreateBusinessLink CreateBusinessLink
ModifyBusinessLinkDiscounting ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
...@@ -1880,6 +1894,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -1880,6 +1894,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing ModifyBusinessLinkTaxing
CreateBusinessLink CreateBusinessLink
ModifyBusinessLinkDiscounting ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
...@@ -1941,6 +1956,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -1941,6 +1956,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing ModifyBusinessLinkTaxing
CreateBusinessLink CreateBusinessLink
ModifyBusinessLinkDiscounting ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
......
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