Commit 1a5123c5 authored by Sebastien Robin's avatar Sebastien Robin

code refactoring

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44442 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fa8f0385
...@@ -560,62 +560,61 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin): ...@@ -560,62 +560,61 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin):
order = self._createDelivery() order = self._createDelivery()
order_line = self._createMovement(order) order_line = self._createMovement(order)
# first level rule with simulation movement # first level rule with simulation movement
applied_rule = self.portal.portal_simulation.newContent( applied_rule = self.portal.portal_simulation.newContent(
portal_type='Applied Rule', causality_value=order) portal_type='Applied Rule', causality_value=order)
simulation_movement = applied_rule.newContent( def setTestClassProperty(prefix, property_name, document):
portal_type = 'Simulation Movement', if prefix:
delivery_value = order_line, property_name = "%s_%s" % (prefix, property_name)
causality_value = self.order_link setattr(self, property_name, document)
) return document
# second level rule with simulation movement def constructSimulationTree(applied_rule, prefix=None):
delivery_rule = simulation_movement.newContent( document = setTestClassProperty(prefix, 'simulation_movement',
portal_type='Applied Rule') applied_rule.newContent(
delivery_simulation_movement = delivery_rule.newContent( portal_type = 'Simulation Movement',
delivery_value = order_line,
causality_value = self.order_link
))
# second level rule with simulation movement
document = setTestClassProperty(prefix, 'delivery_rule',
document.newContent(
portal_type='Applied Rule'))
document = setTestClassProperty(prefix, 'delivery_simulation_movement',
document.newContent(
portal_type='Simulation Movement', portal_type='Simulation Movement',
causality_value = self.delivery_link) causality_value = self.delivery_link))
# third level rule with simulation movement
invoicing_rule = delivery_simulation_movement.newContent(
portal_type='Applied Rule')
invoicing_simulation_movement = invoicing_rule.newContent(
portal_type='Simulation Movement',
causality_value = self.invoice_link)
# split simulation movement for first level applied rule
split_simulation_movement = applied_rule.newContent(
portal_type = 'Simulation Movement', delivery_value = order_line,
causality_value = self.order_link)
# second level rule with simulation movement for split parent movement # third level rule with simulation movement
split_delivery_rule = split_simulation_movement.newContent( document = setTestClassProperty(prefix, 'invoicing_rule',
portal_type='Applied Rule') document.newContent(
split_delivery_simulation_movement = split_delivery_rule.newContent( portal_type='Applied Rule'))
portal_type='Simulation Movement', document = setTestClassProperty(prefix, 'invoicing_simulation_movement',
causality_value = self.delivery_link) document.newContent(
portal_type='Simulation Movement',
causality_value = self.invoice_link))
# third level rule with simulation movement for split parent movement constructSimulationTree(applied_rule)
split_invoicing_rule = split_delivery_simulation_movement.newContent( constructSimulationTree(applied_rule, prefix='split')
portal_type='Applied Rule')
split_invoicing_simulation_movement = split_invoicing_rule.newContent(
portal_type='Simulation Movement',
causality_value = self.invoice_link)
order.setSimulationState(self.completed_state) order.setSimulationState(self.completed_state)
self.stepTic() self.stepTic()
def checkIsBusinessLinkBuildable(explanation, business_link, value):
self.assertEquals(self.business_process.isBusinessLinkBuildable(
explanation, business_link), value)
# in the beginning only order related movements shall be buildable # in the beginning only order related movements shall be buildable
self.assertEquals(self.business_process.isBusinessLinkBuildable( checkIsBusinessLinkBuildable(order, self.delivery_link, True)
order, self.delivery_link), True) self.assertEquals(self.delivery_simulation_movement.isBuildable(), True)
self.assertEquals(delivery_simulation_movement.isBuildable(), True) self.assertEquals(self.split_delivery_simulation_movement.isBuildable(), True)
self.assertEquals(split_delivery_simulation_movement.isBuildable(), True)
self.assertEquals(self.business_process.isBusinessLinkBuildable( checkIsBusinessLinkBuildable(order, self.invoice_link, False)
order, self.invoice_link), False) self.assertEquals(self.invoicing_simulation_movement.isBuildable(), False)
self.assertEquals(invoicing_simulation_movement.isBuildable(), False) self.assertEquals(self.split_invoicing_simulation_movement.isBuildable(),
self.assertEquals(split_invoicing_simulation_movement.isBuildable(),
False) False)
# add delivery # add delivery
...@@ -623,7 +622,7 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin): ...@@ -623,7 +622,7 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin):
delivery_line = self._createMovement(delivery) delivery_line = self._createMovement(delivery)
# relate not split movement with delivery (deliver it) # relate not split movement with delivery (deliver it)
delivery_simulation_movement.edit(delivery_value = delivery_line) self.delivery_simulation_movement.edit(delivery_value = delivery_line)
self.stepTic() self.stepTic()
...@@ -635,20 +634,15 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin): ...@@ -635,20 +634,15 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin):
# #
# delivery_link (for delivery) is not buildable - delivery is already # delivery_link (for delivery) is not buildable - delivery is already
# built for those movements # built for those movements
self.assertEquals(self.business_process.isBusinessLinkBuildable( checkIsBusinessLinkBuildable(order, self.delivery_link, True)
order, self.delivery_link), True) self.assertEquals(self.split_delivery_simulation_movement.isBuildable(), True)
self.assertEquals(split_delivery_simulation_movement.isBuildable(), True)
checkIsBusinessLinkBuildable(delivery, self.delivery_link, False)
self.assertEquals(self.business_process.isBusinessLinkBuildable( checkIsBusinessLinkBuildable(delivery, self.invoice_link, False)
delivery, self.delivery_link), False) self.assertEquals(self.delivery_simulation_movement.isBuildable(), False)
self.assertEquals(self.business_process.isBusinessLinkBuildable( self.assertEquals(self.invoicing_simulation_movement.isBuildable(), False)
delivery, self.invoice_link), False) checkIsBusinessLinkBuildable(order, self.invoice_link, False)
self.assertEquals(delivery_simulation_movement.isBuildable(), False) self.assertEquals(self.split_invoicing_simulation_movement.isBuildable(), False)
self.assertEquals(invoicing_simulation_movement.isBuildable(), False)
self.assertEquals(self.business_process.isBusinessLinkBuildable(
order, self.invoice_link), False)
self.assertEquals(split_invoicing_simulation_movement.isBuildable(),
False)
# put delivery in simulation state configured on path (and this state is # put delivery in simulation state configured on path (and this state is
# available directly on movements) # available directly on movements)
...@@ -669,20 +663,15 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin): ...@@ -669,20 +663,15 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin):
# #
# split movement for invoicing is not buildable - no proper delivery # split movement for invoicing is not buildable - no proper delivery
# related for previous path # related for previous path
self.assertEquals(self.business_process.isBusinessLinkBuildable( checkIsBusinessLinkBuildable(order, self.delivery_link, True)
order, self.delivery_link), True) self.assertEquals(self.invoicing_simulation_movement.isBuildable(), True)
self.assertEquals(invoicing_simulation_movement.isBuildable(), True) checkIsBusinessLinkBuildable(delivery, self.invoice_link, True)
self.assertEquals(self.business_process.isBusinessLinkBuildable(
delivery, self.invoice_link), True) checkIsBusinessLinkBuildable(order, self.invoice_link, False)
checkIsBusinessLinkBuildable(delivery, self.invoice_link, True)
self.assertEquals(self.business_process.isBusinessLinkBuildable( checkIsBusinessLinkBuildable(delivery, self.delivery_link, False)
order, self.invoice_link), False) self.assertEquals(self.delivery_simulation_movement.isBuildable(), False)
self.assertEquals(self.business_process.isBusinessLinkBuildable( self.assertEquals(self.split_invoicing_simulation_movement.isBuildable(),
delivery, self.invoice_link), True)
self.assertEquals(self.business_process.isBusinessLinkBuildable(
delivery, self.delivery_link), False)
self.assertEquals(delivery_simulation_movement.isBuildable(), False)
self.assertEquals(split_invoicing_simulation_movement.isBuildable(),
False) False)
@newSimulationExpectedFailure @newSimulationExpectedFailure
......
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