Commit f8afe1e8 authored by Julien Muchembled's avatar Julien Muchembled

Fix testLegacyTradeModelLine WRT r42117

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42133 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0d93c597
...@@ -180,9 +180,13 @@ class TestTradeModelLineMixin(TestBPMMixin, UserDict): ...@@ -180,9 +180,13 @@ class TestTradeModelLineMixin(TestBPMMixin, UserDict):
order.newContent(portal_type=self.order_line_portal_type, **line_kw) order.newContent(portal_type=self.order_line_portal_type, **line_kw)
return order return order
def getAggregatedAmountList(self, amount_generator, *args, **kw):
return amount_generator.getAggregatedAmountList(*args, **kw)
def getAggregatedAmountDict(self, amount_generator, partial_check=False, def getAggregatedAmountDict(self, amount_generator, partial_check=False,
ignore_empty_amounts=False,
**expected_amount_dict): **expected_amount_dict):
amount_list = amount_generator.getAggregatedAmountList() amount_list = self.getAggregatedAmountList(amount_generator)
amount_dict = {} amount_dict = {}
for amount in amount_list: for amount in amount_list:
reference = amount.getReference() reference = amount.getReference()
...@@ -789,7 +793,7 @@ return lambda *args, **kw: 1""") ...@@ -789,7 +793,7 @@ return lambda *args, **kw: 1""")
order = self.createOrder(trade_condition, ( order = self.createOrder(trade_condition, (
dict(), dict(),
)) ))
self.assertEqual([], order.getAggregatedAmountList()) self.assertEqual([], self.getAggregatedAmountList(order))
for line in trade_condition.objectValues(): for line in trade_condition.objectValues():
line.setBaseApplication(fixed_quantity) line.setBaseApplication(fixed_quantity)
amount_list = order.getAggregatedAmountList() amount_list = order.getAggregatedAmountList()
......
...@@ -41,6 +41,11 @@ def test_suite(): ...@@ -41,6 +41,11 @@ def test_suite():
suite.addTest(unittest.makeSuite(TestComplexTradeModelLineUseCasePurchase)) suite.addTest(unittest.makeSuite(TestComplexTradeModelLineUseCasePurchase))
return suite return suite
def getAggregatedAmountList(self, amount_generator, *args, **kw):
kw.setdefault('generate_empty_amounts', False)
return amount_generator.getAggregatedAmountList(*args, **kw)
TestTradeModelLineMixin.getAggregatedAmountList = getAggregatedAmountList
### ###
## TestTradeModelLine ## TestTradeModelLine
## ##
...@@ -143,6 +148,8 @@ def checkTradeModelRuleSimulationExpand(self, delivery): ...@@ -143,6 +148,8 @@ def checkTradeModelRuleSimulationExpand(self, delivery):
['base_amount/' + use]) ['base_amount/' + use])
self.assertEqual(sm.getBaseContributionList(), self.assertEqual(sm.getBaseContributionList(),
dict(discount=['base_amount/tax'], tax=[])[use]) dict(discount=['base_amount/tax'], tax=[])[use])
self.assertEqual({}, result_dict) # Ignore SM that were created from empty amounts
self.assertEqual({}, dict(x for x in result_dict.iteritems()
if x[1].getQuantity()))
TestTradeModelLine.checkTradeModelRuleSimulationExpand = \ TestTradeModelLine.checkTradeModelRuleSimulationExpand = \
checkTradeModelRuleSimulationExpand checkTradeModelRuleSimulationExpand
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