Commit 775cbde1 authored by Łukasz Nowak's avatar Łukasz Nowak

- implement test for ordered, invoiced and delivered business process with...

 - implement test for ordered, invoiced and delivered business process with sequence not related to appearance of simulation tree with using of compensation
 - explain more in docstrings about tests
 - add comments relating to isBuildable implementation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28127 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 53bb6ff2
...@@ -619,8 +619,13 @@ class TestBPMisBuildableImplementation(TestBPMMixin): ...@@ -619,8 +619,13 @@ class TestBPMisBuildableImplementation(TestBPMMixin):
self.stepTic() self.stepTic()
def test_isBuildable_OrderedDeliveredInvoiced(self): def test_isBuildable_OrderedDeliveredInvoiced(self):
"""Test isBuildable implementation for Business Paths and Simulation Movements""" """Test isBuildable for ordered, delivered and invoiced sequence
Here Business Process sequence corresponds simulation tree.
delivery_path is related to root applied rule, and invoice_path is related
to rule below, and invoice_path is after delivery_path
"""
# simple business process preparation # simple business process preparation
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
ordered = self.createBusinessState(business_process) ordered = self.createBusinessState(business_process)
...@@ -728,6 +733,8 @@ class TestBPMisBuildableImplementation(TestBPMMixin): ...@@ -728,6 +733,8 @@ class TestBPMisBuildableImplementation(TestBPMMixin):
self.assertEquals(delivery_path.isBuildable(order), True) self.assertEquals(delivery_path.isBuildable(order), True)
self.assertEquals(invoicing_simulation_movement.isBuildable(), True) self.assertEquals(invoicing_simulation_movement.isBuildable(), True)
self.assertEquals(invoice_path.isBuildable(delivery), True) self.assertEquals(invoice_path.isBuildable(delivery), True)
# XXX look at comments in BusinessPath.isBuildable
self.assertEquals(invoice_path.isBuildable(order), True) self.assertEquals(invoice_path.isBuildable(order), True)
self.assertEquals(delivery_path.isBuildable(delivery), False) self.assertEquals(delivery_path.isBuildable(delivery), False)
...@@ -735,6 +742,119 @@ class TestBPMisBuildableImplementation(TestBPMMixin): ...@@ -735,6 +742,119 @@ class TestBPMisBuildableImplementation(TestBPMMixin):
self.assertEquals(split_invoicing_simulation_movement.isBuildable(), self.assertEquals(split_invoicing_simulation_movement.isBuildable(),
False) False)
def test_isBuildable_OrderedInvoicedDelivered(self):
"""Test isBuildable for ordered, invoiced and delivered sequence
Here Business Process sequence do not corresponds simulation tree.
delivery_path is related to root applied rule, and invoice_path is related
to rule below, but invoice_path is before delivery_path in seuqence.
"""
business_process = self.createBusinessProcess()
ordered = self.createBusinessState(business_process)
delivered = self.createBusinessState(business_process)
invoiced = self.createBusinessState(business_process)
invoice_path = self.createBusinessPath(business_process,
predecessor_value = ordered, successor_value = invoiced,
trade_phase='default/invoicing', completed_state_list = ['confirmed'])
delivery_path = self.createBusinessPath(business_process,
predecessor_value = invoiced, successor_value = delivered,
trade_phase='default/delivery')
order = self._createDelivery()
order_line = self._createMovement(order)
applied_rule = self.portal.portal_simulation.newContent(
portal_type='Applied Rule', causality_value=order)
simulation_movement = applied_rule.newContent(
portal_type = 'Simulation Movement',
order_value = order_line,
causality_value = delivery_path
)
invoicing_rule = simulation_movement.newContent(
portal_type='Applied Rule')
invoicing_simulation_movement = invoicing_rule.newContent(
portal_type='Simulation Movement', causality_value = invoice_path)
self.stepTic()
self.assertEquals(delivery_path.isBuildable(order), False)
self.assertEquals(simulation_movement.isBuildable(), False)
self.assertEquals(invoice_path.isBuildable(order), True)
self.assertEquals(invoicing_simulation_movement.isBuildable(), True)
delivery = self._createDelivery(causality_value = order)
delivery_line = self._createMovement(delivery)
invoicing_simulation_movement.edit(delivery_value = delivery_line)
self.stepTic()
self.assertEquals(delivery_path.isBuildable(order), False)
self.assertEquals(delivery_path.isBuildable(delivery), False)
self.assertEquals(invoice_path.isBuildable(delivery), False)
self.assertEquals(simulation_movement.isBuildable(), False)
self.assertEquals(invoicing_simulation_movement.isBuildable(), False)
self.assertEquals(invoice_path.isBuildable(order), False)
# put delivery in simulation state configured on path (and this state is
# available directly on movements)
delivery.setSimulationState('confirmed')
self.assertEqual('confirmed', delivery.getSimulationState())
self.stepTic()
self.assertEquals(delivery_path.isBuildable(order), True)
self.assertEquals(delivery_path.isBuildable(delivery), True)
self.assertEquals(invoicing_simulation_movement.isBuildable(), False)
self.assertEquals(invoice_path.isBuildable(delivery), False)
self.assertEquals(invoice_path.isBuildable(order), False)
self.assertEquals(simulation_movement.isBuildable(), True)
# now simulate compensation
compensated_simulation_movement = applied_rule.newContent(
portal_type = 'Simulation Movement',
order_value = order_line,
causality_value = delivery_path
)
compensated_invoicing_rule = compensated_simulation_movement.newContent(
portal_type='Applied Rule')
compensated_invoicing_simulation_movement = compensated_invoicing_rule.newContent(
portal_type='Simulation Movement', causality_value = invoice_path)
# and delivery some part of tree
another_delivery = self._createDelivery(causality_value = delivery)
another_delivery_line = self._createMovement(another_delivery)
simulation_movement.edit(delivery_value=another_delivery_line)
self.stepTic()
# XXX look at comments in BusinessPath.isBuildable
# in this case expected result if False for delivery_path.isBuildable(order)
self.assertEquals(delivery_path.isBuildable(order), True)
self.assertEquals(delivery_path.isBuildable(delivery), False)
self.assertEquals(simulation_movement.isBuildable(), False)
self.assertEquals(invoicing_simulation_movement.isBuildable(), False)
self.assertEquals(invoice_path.isBuildable(order), True)
self.assertEquals(compensated_invoicing_simulation_movement.isBuildable(), True)
self.assertEquals(compensated_simulation_movement.isBuildable(), False)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestBPMImplementation)) suite.addTest(unittest.makeSuite(TestBPMImplementation))
......
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