Commit 4536c013 authored by Nicolas Dumazet's avatar Nicolas Dumazet

test&implement TransformedResource.getAggregatedAmountList(a) if a.quantity <> 1


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33746 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c63b1ea5
...@@ -263,6 +263,15 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount): ...@@ -263,6 +263,15 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount):
except ValueError: except ValueError:
error_string += 'Quantity is not a float.' error_string += 'Quantity is not a float.'
# If IAmount specifies that 4 resources are needed, all quantities
# need to be multiplicated by 4...
context_quantity = None
quantity_getter = getattr(context, "getQuantity", None)
if quantity_getter is not None:
context_quantity = quantity_getter()
if context_quantity is None:
raise KeyError("No quantity defined on context")
quantity *= float(context_quantity)
# Get the variation category list # Get the variation category list
variation_category_list_defined_by = None variation_category_list_defined_by = None
......
...@@ -242,6 +242,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -242,6 +242,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
len(fabric_line.getCellKeyList(base_id='quantity')) len(fabric_line.getCellKeyList(base_id='quantity'))
) )
swimsuit_quantity = 4.0
from Products.ERP5Type.Document import newTempAmount from Products.ERP5Type.Document import newTempAmount
n = 1 n = 1
# Check that getAggregatedAmount returns the expected results, a.k.a. # Check that getAggregatedAmount returns the expected results, a.k.a.
...@@ -251,7 +252,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -251,7 +252,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
# id does not matter, just make it unique # id does not matter, just make it unique
temp_amount = newTempAmount(transformation, "foo_%s_%s" % (size, colour)) temp_amount = newTempAmount(transformation, "foo_%s_%s" % (size, colour))
temp_amount.edit( temp_amount.edit(
quantity = 1.0, quantity = swimsuit_quantity,
variation_category_list = [size, colour], variation_category_list = [size, colour],
resource = swimsuit.getRelativeUrl(), resource = swimsuit.getRelativeUrl(),
) )
...@@ -262,12 +263,12 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -262,12 +263,12 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
resource = amount.getResource() resource = amount.getResource()
if resource == fabric.getRelativeUrl(): if resource == fabric.getRelativeUrl():
self.assertEquals(amount.getVariationCategoryList(), [colour]) self.assertEquals(amount.getVariationCategoryList(), [colour])
self.assertEquals(amount.getQuantity(), i+1) self.assertEquals(amount.getQuantity(), (i+1)*swimsuit_quantity)
elif resource == button.getRelativeUrl(): elif resource == button.getRelativeUrl():
self.assertEquals(amount.getVariationCategoryList(), [size]) self.assertEquals(amount.getVariationCategoryList(), [size])
self.assertEquals(amount.getQuantity(), button_number) self.assertEquals(amount.getQuantity(), button_number*swimsuit_quantity)
elif resource == "operation/sewing": elif resource == "operation/sewing":
self.assertEquals(amount.getQuantity(), n) self.assertEquals(amount.getQuantity(), n*swimsuit_quantity)
else: else:
self.fail("Invalid Resource: %s" % resource) self.fail("Invalid Resource: %s" % resource)
n += 1 n += 1
......
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