Commit 6181ad9a authored by Nicolas Dumazet's avatar Nicolas Dumazet

extend test: check aggregation for the whole transformation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33744 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 87c1ce11
...@@ -149,6 +149,8 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -149,6 +149,8 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
def test_transformedInventory(self): def test_transformedInventory(self):
portal = self.getPortal() portal = self.getPortal()
button_number = 3.0
swimsuit = self.createResource( swimsuit = self.createResource(
'Swimming Suit', 'Swimming Suit',
self.swimsuit_variation_base_category_list, self.swimsuit_variation_base_category_list,
...@@ -199,6 +201,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -199,6 +201,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
button_line = self.createTransformedResource(transformation) button_line = self.createTransformedResource(transformation)
button_line.setResourceValue(button) button_line.setResourceValue(button)
button_line.setQuantity(button_number)
button_line.setVVariationBaseCategoryList(['size']) button_line.setVVariationBaseCategoryList(['size'])
for size in self.size_category_list: for size in self.size_category_list:
...@@ -240,20 +243,34 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -240,20 +243,34 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
) )
from Products.ERP5Type.Document import newTempAmount from Products.ERP5Type.Document import newTempAmount
n = 1
# Check that getAggregatedAmount returns the expected results, a.k.a.
# that our Transformation is set up correctly.
for i, size in enumerate(self.size_category_list): for i, size in enumerate(self.size_category_list):
for colour in self.colour_category_list: for colour in self.colour_category_list:
# id does not matter, just make it unique # id does not matter, just make it unique
a = newTempAmount(transformation, "foo_%s_%s" % (size, colour)) temp_amount = newTempAmount(transformation, "foo_%s_%s" % (size, colour))
a.edit( temp_amount.edit(
quantity = 1.0, quantity = 1.0,
variation_category_list = [size, colour], variation_category_list = [size, colour],
resource = swimsuit.getRelativeUrl(), resource = swimsuit.getRelativeUrl(),
) )
ag = fabric_line.getAggregatedAmountList(a) amount_list = transformation.getAggregatedAmountList(temp_amount)
self.assertEquals(len(ag), 1) # fabric + button + sewing
self.assertEquals(ag[0].getResource(), fabric.getRelativeUrl()) self.assertEquals(len(amount_list), 3)
self.assertEquals(ag[0].getVariationCategoryList(), [colour]) for amount in amount_list:
self.assertEquals(ag[0].quantity, i+1) resource = amount.getResource()
if resource == fabric.getRelativeUrl():
self.assertEquals(amount.getVariationCategoryList(), [colour])
self.assertEquals(amount.getQuantity(), i+1)
elif resource == button.getRelativeUrl():
self.assertEquals(amount.getVariationCategoryList(), [size])
self.assertEquals(amount.getQuantity(), button_number)
elif resource == "operation/sewing":
self.assertEquals(amount.getQuantity(), n)
else:
self.fail("Invalid Resource: %s" % resource)
n += 1
# XXX (will be expanded) # XXX (will be expanded)
......
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