Commit c423adbe authored by Romain Courteaud's avatar Romain Courteaud

Add some tests.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3141 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e076ae47
...@@ -210,10 +210,10 @@ class TestOrder(ERP5TypeTestCase): ...@@ -210,10 +210,10 @@ class TestOrder(ERP5TypeTestCase):
stop_date = self.datetime + 20, stop_date = self.datetime + 20,
) )
if organisation is not None: if organisation is not None:
order.setSourceValue(organisation) order.edit(source_value=organisation,
order.setSourceSectionValue(organisation) source_section_value=organisation,
order.setDestinationValue(organisation) destination_value=organisation,
order.setDestinationSectionValue(organisation) destination_section_value=organisation)
sequence.edit( order = order ) sequence.edit( order = order )
...@@ -360,9 +360,9 @@ class TestOrder(ERP5TypeTestCase): ...@@ -360,9 +360,9 @@ class TestOrder(ERP5TypeTestCase):
cell = order_line.newCell(base_id=base_id, \ cell = order_line.newCell(base_id=base_id, \
portal_type=self.cell_portal_type, *cell_key) portal_type=self.cell_portal_type, *cell_key)
cell.edit(mapped_value_property_list=['price','quantity'], cell.edit(mapped_value_property_list=['price','quantity'],
price=price, quantity=quantity) price=price, quantity=quantity,
cell.setPredicateCategoryList(cell_key) predicate_category_list=cell_key,
cell.setVariationCategoryList(cell_key) variation_category_list=cell_key)
price += 1 price += 1
quantity += 1 quantity += 1
...@@ -606,8 +606,8 @@ class TestOrder(ERP5TypeTestCase): ...@@ -606,8 +606,8 @@ class TestOrder(ERP5TypeTestCase):
Set the default price and quantity on the order line. Set the default price and quantity on the order line.
""" """
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
order_line.setQuantity(self.default_quantity) order_line.edit(quantity=self.default_quantity,
order_line.setPrice(self.default_price) price=self.default_price)
def stepCheckOrderLineDefaultValues(self, sequence=None, \ def stepCheckOrderLineDefaultValues(self, sequence=None, \
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -1391,8 +1391,8 @@ class TestOrder(ERP5TypeTestCase): ...@@ -1391,8 +1391,8 @@ class TestOrder(ERP5TypeTestCase):
organisation1 = sequence.get('organisation1') organisation1 = sequence.get('organisation1')
organisation2 = sequence.get('organisation2') organisation2 = sequence.get('organisation2')
order = sequence.get('order') order = sequence.get('order')
order.setSourceValue(organisation1) order.edit(source_value=organisation1,
order.setDestinationValue(organisation2) destination_value=organisation2)
def stepCheckDeliveryBuilding(self, sequence=None, sequence_list=None, **kw): def stepCheckDeliveryBuilding(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -1404,7 +1404,7 @@ class TestOrder(ERP5TypeTestCase): ...@@ -1404,7 +1404,7 @@ class TestOrder(ERP5TypeTestCase):
related_packing_list_list = order.getCausalityRelatedValueList( \ related_packing_list_list = order.getCausalityRelatedValueList( \
portal_type=self.packing_list_portal_type) portal_type=self.packing_list_portal_type)
packing_list_building_state = ('confirmed', ) packing_list_building_state = 'confirmed'
order_state = order.getSimulationState() order_state = order.getSimulationState()
if order_state not in packing_list_building_state: if order_state not in packing_list_building_state:
self.assertEquals(0, len(related_packing_list_list)) self.assertEquals(0, len(related_packing_list_list))
...@@ -1417,6 +1417,10 @@ class TestOrder(ERP5TypeTestCase): ...@@ -1417,6 +1417,10 @@ class TestOrder(ERP5TypeTestCase):
applied_rule = related_applied_rule_list[0].getObject() applied_rule = related_applied_rule_list[0].getObject()
simulation_movement_list = applied_rule.objectValues() simulation_movement_list = applied_rule.objectValues()
# Test that packing list is confirmed
packing_list_state = packing_list.getSimulationState()
self.assertEquals(packing_list_building_state, packing_list_state)
# First, test if each Simulation Movement is related to a Packing List # First, test if each Simulation Movement is related to a Packing List
# Movement # Movement
packing_list_relative_url = packing_list.getRelativeUrl() packing_list_relative_url = packing_list.getRelativeUrl()
...@@ -1445,11 +1449,12 @@ class TestOrder(ERP5TypeTestCase): ...@@ -1445,11 +1449,12 @@ class TestOrder(ERP5TypeTestCase):
related_simulation_movement_list = packing_list_movement.\ related_simulation_movement_list = packing_list_movement.\
getDeliveryRelatedValueList(portal_type='Simulation Movement') getDeliveryRelatedValueList(portal_type='Simulation Movement')
quantity = 0 quantity = 0
total_price = 0
packing_list_movement_quantity = packing_list_movement.getQuantity()
for related_simulation_movement in related_simulation_movement_list: for related_simulation_movement in related_simulation_movement_list:
quantity += related_simulation_movement.getQuantity() quantity += related_simulation_movement.getQuantity()
# Test price total_price += related_simulation_movement.getPrice() *\
self.assertEquals(packing_list_movement.getPrice(), \ related_simulation_movement.getQuantity()
related_simulation_movement.getPrice())
# Test resource # Test resource
self.assertEquals(packing_list_movement.getResource(), \ self.assertEquals(packing_list_movement.getResource(), \
related_simulation_movement.getResource()) related_simulation_movement.getResource())
...@@ -1461,7 +1466,15 @@ class TestOrder(ERP5TypeTestCase): ...@@ -1461,7 +1466,15 @@ class TestOrder(ERP5TypeTestCase):
# Test acquisition # Test acquisition
self.checkAcquisition(packing_list_movement, self.checkAcquisition(packing_list_movement,
related_simulation_movement) related_simulation_movement)
# Test delivery ratio
self.assertEquals(related_simulation_movement.getQuantity() /\
packing_list_movement_quantity, \
related_simulation_movement.getDeliveryRatio())
self.assertEquals(quantity, packing_list_movement.getQuantity()) self.assertEquals(quantity, packing_list_movement.getQuantity())
# Test price
self.assertEquals(total_price / quantity, packing_list_movement.getPrice())
# Finally, test Packing List getTotalQuantity and getTotalPrice # Finally, test Packing List getTotalQuantity and getTotalPrice
self.assertEquals(order.getTotalQuantity(), packing_list.getTotalQuantity()) self.assertEquals(order.getTotalQuantity(), packing_list.getTotalQuantity())
...@@ -1550,30 +1563,83 @@ class TestOrder(ERP5TypeTestCase): ...@@ -1550,30 +1563,83 @@ class TestOrder(ERP5TypeTestCase):
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
# XXX Not yet implemented # XXX Does not work yet
# # Test with a order with 2 lines and the same not variated resource # # Test to confirm order without doing any tic
# sequence_string = '\ # sequence_string = '\
# CreateOrganisation1 \ # CreateOrganisation1 \
# CreateOrganisation2 \ # CreateOrganisation2 \
# CreateOrder \ # CreateOrder \
# SetOrderProfile \ # SetOrderProfile \
# CreateNotVariatedResource \ # CreateVariatedResource \
# Tic \
# CreateOrderLine \ # CreateOrderLine \
# SetOrderLineResource \ # SetOrderLineResource \
# SetOrderLineDefaultValues \ # SetOrderLineDefaultValues \
# SetOrderLineFullVCL \
# CompleteOrderLineMatrix \
# CreateNotVariatedResource \
# CreateOrderLine \ # CreateOrderLine \
# SetOrderLineResource \ # SetOrderLineResource \
# SetOrderLineDefaultValues \ # SetOrderLineDefaultValues \
# OrderOrder \ # OrderOrder \
# Tic \
# CheckDeliveryBuilding \ # CheckDeliveryBuilding \
# ConfirmOrder \ # ConfirmOrder \
# Tic \ # Tic \
# Tic \
# CheckDeliveryBuilding \ # CheckDeliveryBuilding \
# ' # '
# sequence_list.addSequenceString(sequence_string) # sequence_list.addSequenceString(sequence_string)
# Test with a order with 2 lines and the same not variated resource
sequence_string = '\
CreateOrganisation1 \
CreateOrganisation2 \
CreateOrder \
SetOrderProfile \
CreateNotVariatedResource \
Tic \
CreateOrderLine \
SetOrderLineResource \
SetOrderLineDefaultValues \
CreateOrderLine \
SetOrderLineResource \
SetOrderLineDefaultValues \
OrderOrder \
Tic \
CheckDeliveryBuilding \
ConfirmOrder \
Tic \
CheckDeliveryBuilding \
'
sequence_list.addSequenceString(sequence_string)
# Test with a order with 2 lines and the same variated resource
sequence_string = '\
CreateOrganisation1 \
CreateOrganisation2 \
CreateOrder \
SetOrderProfile \
CreateVariatedResource \
Tic \
CreateOrderLine \
SetOrderLineResource \
SetOrderLineDefaultValues \
SetOrderLineFullVCL \
CompleteOrderLineMatrix \
CreateOrderLine \
SetOrderLineResource \
SetOrderLineDefaultValues \
SetOrderLineFullVCL \
CompleteOrderLineMatrix \
Tic \
OrderOrder \
Tic \
CheckDeliveryBuilding \
ConfirmOrder \
Tic \
CheckDeliveryBuilding \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
# XXX # XXX
......
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