diff --git a/product/ERP5/tests/testBPMCore.py b/product/ERP5/tests/testBPMCore.py index 9a830512f623349736239c56df4934a9d09b6d5e..36f3971960e8ec6e4265705159941c09065f740c 100644 --- a/product/ERP5/tests/testBPMCore.py +++ b/product/ERP5/tests/testBPMCore.py @@ -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() diff --git a/product/ERP5/tests/testTradeModelLine.py b/product/ERP5/tests/testTradeModelLine.py index ad716962e8f80d422dd8e1fa297adcf230af3d89..6338ae3feccc2350fa2bab208cd71d821d1da50b 100644 --- a/product/ERP5/tests/testTradeModelLine.py +++ b/product/ERP5/tests/testTradeModelLine.py @@ -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