[Erp5-report] r33831 nicolas.dumazet - in /erp5/trunk/products/ERP5: Document/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Mar 18 04:38:02 CET 2010


Author: nicolas.dumazet
Date: Thu Mar 18 04:38:02 2010
New Revision: 33831

URL: http://svn.erp5.org?rev=33831&view=rev
Log:
Fix wrong behaviour of Transformation.getAggregatedAmountList:
an Amount context should _always_ be passed to this method.

this fixes TestTransformation.test_01_getAggregatedAmountListSimple

Modified:
    erp5/trunk/products/ERP5/Document/Transformation.py
    erp5/trunk/products/ERP5/Document/TransformedResource.py
    erp5/trunk/products/ERP5/tests/testTransformation.py

Modified: erp5/trunk/products/ERP5/Document/Transformation.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Transformation.py?rev=33831&r1=33830&r2=33831&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Transformation.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Transformation.py [utf8] Thu Mar 18 04:38:02 2010
@@ -31,6 +31,8 @@
 ##############################################################################
 
 import zope.interface
+
+from warnings import warn
 from AccessControl import ClassSecurityInfo
 
 from Products.ERP5Type import Permissions, PropertySheet, interfaces
@@ -247,7 +249,15 @@
         can be used either to do some calculation (ex. price, BOM)
         or to display a detailed view of a transformation.
       """
-      context = self.asContext(context=context, REQUEST=REQUEST, **kw)
+      if context is None:
+        warn("Calling Transformation.getAggregatedAmountList without context " \
+             "is wrong. Context should be an Amount defining the resource to " \
+             "produce", DeprecationWarning)
+        from Products.ERP5Type.Document import newTempAmount
+        context = newTempAmount(self, "deprecated_usage")
+        context.setResourceValue(self.getResourceValue())
+        context.setQuantity(1.0)
+
 
       # A list of functions taking a transformation_line as sole argument
       # and returning True iif the line should be kept in the result

Modified: erp5/trunk/products/ERP5/Document/TransformedResource.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TransformedResource.py?rev=33831&r1=33830&r2=33831&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TransformedResource.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TransformedResource.py [utf8] Thu Mar 18 04:38:02 2010
@@ -133,13 +133,12 @@
 
     security.declareProtected(Permissions.AccessContentsInformation, 
                               'getAggregatedAmountList')
-    def getAggregatedAmountList(self, context=None, REQUEST=None, **kw):
+    def getAggregatedAmountList(self, context, REQUEST=None, **kw):
       """
         Get all interesting amount value and return AggregatedAmountList
       """
       from Products.ERP5Type.Document import newTempAmount
 
-      context = self.asContext(context=context, REQUEST=REQUEST, **kw)
       # Create the result object
       aggregated_amount_list = AggregatedAmountList()
       test_result = self.test(context)

Modified: erp5/trunk/products/ERP5/tests/testTransformation.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testTransformation.py?rev=33831&r1=33830&r2=33831&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testTransformation.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testTransformation.py [utf8] Thu Mar 18 04:38:02 2010
@@ -108,9 +108,11 @@
     component = self.createComponent()
     transformed_resource.edit(
         resource_value=component,
-        quantity=1)
+        quantity=2)
     aggregated_amount_list = transformation.getAggregatedAmountList()
     self.assertEquals(len(aggregated_amount_list), 1)
+    aggregated_amount = aggregated_amount_list[0]
+    self.assertEquals(aggregated_amount.quantity, 2)
 
   def test_01_getAggregatedAmountListWithVariatedProperty(self):
     """




More information about the Erp5-report mailing list