Commit 54f2a76e authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

override checkOrderRuleSimulation and...

override checkOrderRuleSimulation and stepModifySimulationLineQuantityForMergedLine to follow aggegation in expanding to simulation movements.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31502 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7592927e
......@@ -32,6 +32,8 @@ This test is experimental for new simulation implementation.
import unittest
import transaction
from zLOG import LOG
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from testPackingList import TestPackingList, TestPackingListMixin
......@@ -452,6 +454,83 @@ class TestERP5SimulationPackingList(TestERP5SimulationMixin, TestPackingList):
solver_process.buildTargetSolverList()
solver_process.solve()
def checkOrderRuleSimulation(self, rule_reference, sequence=None, sequence_list=None, **kw):
"""
Test if simulation is matching order, be sure that rule_reference is used
to expand simulation for order
"""
order = sequence.get('order')
related_applied_rule_list = order.getCausalityRelatedValueList( \
portal_type=self.applied_rule_portal_type)
no_applied_rule_state = ('draft', 'auto_planned')
order_state = order.getSimulationState()
if order_state in no_applied_rule_state:
self.assertEquals(0, len(related_applied_rule_list))
else:
LOG('stepCheckOrderRuleSimulation', 0, 'related_applied_rule_list: %s' %
str([x.getObject() for x in related_applied_rule_list]))
self.assertEquals(1, len(related_applied_rule_list))
applied_rule = related_applied_rule_list[0].getObject()
sequence.edit(applied_rule=applied_rule)
self.failUnless(applied_rule is not None)
self.failUnless(order_state, \
applied_rule.getLastExpandSimulationState())
# Test if applied rule has a specialise value with passed rule_reference
portal_rules = getToolByName(order, 'portal_rules')
self.assertEquals(rule_reference,
applied_rule.getSpecialiseReference())
simulation_movement_list = applied_rule.objectValues()
sequence.edit(simulation_movement_list=simulation_movement_list)
# Count the number of movement in order
movement_list = order.getMovementList()
# Check if number of unique movement is equal to number of
# simulation movement
unique_movement_list = dict(
[('%r,%r,%r' % (x.getResource(), x.getVariationCategoryList(),
x.getVariationPropertyDict())), x] for x in movement_list).values()
self.assertEquals(len(unique_movement_list),
len(simulation_movement_list))
# Check if all movements are related to simulation movements
order_movement_list = sum([x.getOrderValueList() for x in \
simulation_movement_list], [])
self.failIfDifferentSet(movement_list, order_movement_list)
# Check each simulation movement
for simulation_movement in simulation_movement_list:
order_movement_list = simulation_movement.getOrderValueList()
# Test quantity
self.assertEquals(sum([x.getQuantity() for x in order_movement_list]),
simulation_movement.getQuantity())
for order_movement in order_movement_list:
# Test price
self.assertEquals(order_movement.getPrice(), \
simulation_movement.getPrice())
# Test resource
self.assertEquals(order_movement.getResource(), \
simulation_movement.getResource())
# Test resource variation
self.assertEquals(order_movement.getVariationText(), \
simulation_movement.getVariationText())
self.assertEquals(order_movement.getVariationCategoryList(), \
simulation_movement.getVariationCategoryList())
# XXX Test acquisition
self.checkAcquisition(simulation_movement, order_movement)
def stepModifySimulationLineQuantityForMergedLine(self,sequence=None, sequence_list=None, **kw):
"""
Check if simulation movement are disconnected
"""
applied_rule = sequence.get('applied_rule')
simulation_line_list = applied_rule.objectValues()
self.assertEquals(len(simulation_line_list), 1)
for simulation_line in simulation_line_list:
simulation_line.edit(quantity=self.default_quantity-2)
simulation_line.getOrderValue().edit(quantity=self.default_quantity-2)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Simulation))
......
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