Commit baae1a07 authored by Nicolas Dumazet's avatar Nicolas Dumazet

Expand a bit testTransformation. The added test is failing at the moment.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33610 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ea77d3e
......@@ -27,15 +27,16 @@
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from testProductionOrder import TestProductionOrderMixin
import transaction
class TestTransformationMixin:
class TestTransformationMixin(TestProductionOrderMixin):
"""
Mixin class for checking transformations
"""
transformation_portal_type = 'Transformation'
transformed_resource_portal_type = \
'Transformation Transformed Resource'
component_portal_type = 'Component'
# Override, let TestProductionOrderMixin define the categories for us
operation_category_list = ['sewing', 'packing']
def createTransformation(self):
module = self.getPortalObject().getDefaultModule(
......@@ -55,6 +56,42 @@ class TestTransformationMixin:
component.setVariationPropertyList(variation_property_list)
return component
def createResource(self, title, variation_base_category_list,
variation_category_list):
portal = self.getPortal()
resource_module = portal.getDefaultModule(self.resource_portal_type)
resource = resource_module.newContent(portal_type=self.resource_portal_type)
resource.edit(
title = title,
variation_base_category_list = variation_base_category_list,
)
resource.setVariationCategoryList(variation_category_list)
return resource
size_category_list = ['size/' + q for q in TestProductionOrderMixin
.mrp_size_list]
colour_category_list = ['colour/' + q for q in TestProductionOrderMixin
.colour_list]
swimsuit_variation_base_category_list = ['size', 'colour']
swimsuit_variation_category_list = size_category_list + colour_category_list
fabric_variation_base_category_list = ['colour']
fabric_variation_category_list = colour_category_list
button_variation_base_category_list = ['size']
button_variation_category_list = size_category_list
def createButtonComponent(self):
"""
Buttons, variated by size
"""
resource = self.createComponent()
resource.edit(
title = "Round Button",
variation_base_category_list = self.button_variation_base_category_list,
)
resource.setVariationCategoryList(self.button_variation_category_list)
class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
def getBusinessTemplateList(self):
......@@ -89,6 +126,82 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
# temp object
self.assertTrue(aggregated_amount.isTested())
def test_transformedInventory(self):
portal = self.getPortal()
swimsuit = self.createResource(
'Swimming Suit',
self.swimsuit_variation_base_category_list,
self.swimsuit_variation_category_list,
)
transformation = self.createTransformation()
transformation.edit(
title = 'Swimsuit Production',
variation_base_category_list = self.swimsuit_variation_base_category_list
)
transformation.setResourceValue(swimsuit)
fabric = self.createResource(
'Fabric',
self.fabric_variation_base_category_list,
self.fabric_variation_category_list,
)
fabric_line = self.createTransformedResource(transformation)
fabric_line.setResourceValue(fabric)
fabric_line.setVVariationBaseCategoryList(['colour'])
for colour in self.colour_category_list:
# For a blue swimming suit, we need blue fabric
fabric_line.newCell(colour, category = colour, base_id = 'variation')
fabric_line.setQVariationBaseCategoryList(['size'])
for i, size in enumerate(self.size_category_list):
# Depending on the size, the quantity of Fabric is different.
# arbitrarily, we fix the quantity for size s as:
# self.size_category_list.index(s) + 1
fabric_line.newCell(size, quantity = i+1, base_id = 'quantity')
button = self.createComponent()
button.edit(
title = 'Round Button',
variation_base_category_list = self.button_variation_base_category_list,
)
button.setVariationCategoryList(self.button_variation_category_list)
button_line = self.createTransformedResource(transformation)
button_line.setResourceValue(button)
button_line.setVVariationBaseCategoryList(['size'])
for size in self.size_category_list:
# The button used depends on the size
button_line.newCell(size, category = size, base_id = 'variation')
sewing_line = transformation.newContent(
portal_type = self.operation_line_portal_type)
sewing_line.setResourceValue(
portal.portal_categories.resolveCategory('operation/sewing'))
sewing_line.setQVariationBaseCategoryList(['size', 'colour'])
i = 1
for size in self.size_category_list:
for colour in self.colour_category_list:
sewing_line.newCell(size, colour, quantity = i, base_id = 'quantity')
i += 1
transaction.commit()
self.tic()
# Swimming Suit does not use ALL categories in Size category.
# As a result, transformation lines should restrict their dimensions,
# using the range induced by the resource, instead of naively
# using the whole range directly from the variation categories.
self.assertEqual(
len(swimsuit.getVariationCategoryList(base_category_list=['size'])),
len(fabric_line.getCellKeyList(base_id='quantity'))
)
# XXX (will be expanded)
def test_resourceIsNotAcquiredOnTransformationLines(self):
'''
We don't want resource define on transformation to be acquired on
......
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