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):
business_process_portal_type = 'Business Process'
business_link_portal_type = 'Business Link'
trade_model_path_portal_type = 'Trade Model Path'
normal_resource_use_category_list = ['normal']
invoicing_resource_use_category_list = ['discount', 'tax']
......@@ -90,6 +91,12 @@ class TestBPMMixin(ERP5TypeTestCase):
portal_type=self.business_link_portal_type, **kw)
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):
# returns a movement for testing
applied_rule = self.portal.portal_simulation.newContent(
......@@ -195,7 +202,12 @@ class TestBPMMixin(ERP5TypeTestCase):
itr.validate()
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.createInvoiceTransactionRule()
self.stepTic()
......
......@@ -37,6 +37,7 @@ from DateTime import DateTime
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestTradeModelLineMixin(TestBPMMixin):
"""Provides methods to implementations sharing similar logic to Trade Model Lines"""
# Constants and variables shared by tests
......@@ -48,18 +49,19 @@ class TestTradeModelLineMixin(TestBPMMixin):
return module.newContent(portal_type=portal_type, **kw)
# Steps
def stepCreatePriceCurrency(self, sequence=None, **kw):
def stepCreatePriceCurrency(self, sequence=None):
sequence.edit(price_currency = self.createResource('Currency', \
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(
title=self.id()))
def stepCreateBusinessLink(self, sequence=None, **kw):
def stepCreateBusinessLink(self, sequence):
business_process = sequence.get('business_process')
sequence.edit(business_link=self.createBusinessLink(business_process))
class TestTradeModelLine(TestTradeModelLineMixin):
quiet = True
......@@ -105,6 +107,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine
......@@ -195,7 +198,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
portal_type='Trade Model Line',
**kw)
def stepModifyBusinessLinkDiscounting(self, sequence=None, **kw):
def stepModifyBusinessLinkDiscounting(self, sequence):
category_tool = self.getCategoryTool()
predecessor = category_tool.trade_state.invoiced
successor = category_tool.trade_state.taxed
......@@ -210,7 +213,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
)
sequence.edit(business_link=None, business_link_discounting=business_link)
def stepModifyBusinessLinkTaxing(self, sequence=None, **kw):
def stepModifyBusinessLinkTaxing(self, sequence):
category_tool = self.getCategoryTool()
predecessor = category_tool.trade_state.invoiced
successor = category_tool.trade_state.taxed
......@@ -225,6 +228,16 @@ class TestTradeModelLine(TestTradeModelLineMixin):
)
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):
invoice = sequence.get('invoice')
solver_process_tool = self.portal.portal_solver_processes
......@@ -1451,6 +1464,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine
......@@ -1880,6 +1894,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine
......@@ -1941,6 +1956,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeModelPath
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
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