From f8afe1e8a3f588df011dc63f0922265e77601e36 Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Fri, 7 Jan 2011 18:23:58 +0000
Subject: [PATCH] Fix testLegacyTradeModelLine WRT r42117

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42133 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testTradeModelLine.py             | 8 ++++++--
 product/ERP5Legacy/tests/testLegacyTradeModelLine.py | 9 ++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/tests/testTradeModelLine.py b/product/ERP5/tests/testTradeModelLine.py
index c8ee0a5264..3da20bd95f 100644
--- a/product/ERP5/tests/testTradeModelLine.py
+++ b/product/ERP5/tests/testTradeModelLine.py
@@ -180,9 +180,13 @@ class TestTradeModelLineMixin(TestBPMMixin, UserDict):
       order.newContent(portal_type=self.order_line_portal_type, **line_kw)
     return order
 
+  def getAggregatedAmountList(self, amount_generator, *args, **kw):
+    return amount_generator.getAggregatedAmountList(*args, **kw)
+
   def getAggregatedAmountDict(self, amount_generator, partial_check=False,
+                              ignore_empty_amounts=False,
                               **expected_amount_dict):
-    amount_list = amount_generator.getAggregatedAmountList()
+    amount_list = self.getAggregatedAmountList(amount_generator)
     amount_dict = {}
     for amount in amount_list:
       reference = amount.getReference()
@@ -789,7 +793,7 @@ return lambda *args, **kw: 1""")
     order = self.createOrder(trade_condition, (
       dict(),
       ))
-    self.assertEqual([], order.getAggregatedAmountList())
+    self.assertEqual([], self.getAggregatedAmountList(order))
     for line in trade_condition.objectValues():
       line.setBaseApplication(fixed_quantity)
     amount_list = order.getAggregatedAmountList()
diff --git a/product/ERP5Legacy/tests/testLegacyTradeModelLine.py b/product/ERP5Legacy/tests/testLegacyTradeModelLine.py
index 4d61c844be..052ac2ff5d 100644
--- a/product/ERP5Legacy/tests/testLegacyTradeModelLine.py
+++ b/product/ERP5Legacy/tests/testLegacyTradeModelLine.py
@@ -41,6 +41,11 @@ def test_suite():
   suite.addTest(unittest.makeSuite(TestComplexTradeModelLineUseCasePurchase))
   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
 ##
@@ -143,6 +148,8 @@ def checkTradeModelRuleSimulationExpand(self, delivery):
                           ['base_amount/' + use])
         self.assertEqual(sm.getBaseContributionList(),
                           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 = \
   checkTradeModelRuleSimulationExpand
-- 
2.30.9