Commit f43b08fb authored by Nicolas Dumazet's avatar Nicolas Dumazet

Extend testTransformation

* test Resource.getDefaultTransformationValue
* add a very basic test for transformed inventories


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34036 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d8bf5be7
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
# #
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from testProductionOrder import TestProductionOrderMixin from testProductionOrder import TestProductionOrderMixin
from testInventoryAPI import BaseTestUnitConversion
import transaction import transaction
class TestTransformationMixin(TestProductionOrderMixin): class TestTransformationMixin(TestProductionOrderMixin):
...@@ -92,12 +92,24 @@ class TestTransformationMixin(TestProductionOrderMixin): ...@@ -92,12 +92,24 @@ class TestTransformationMixin(TestProductionOrderMixin):
resource.setVariationCategoryList(self.button_variation_category_list) resource.setVariationCategoryList(self.button_variation_category_list)
class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): class TestTransformation(TestTransformationMixin, BaseTestUnitConversion):
QUANTITY_UNIT_DICT = {
# base: (reference, dict_of_others)
'mass': ('kilogram', dict(gram=0.001)),
}
METRIC_TYPE_CATEGORY_LIST = (
'mass/net',
)
def afterSetUp(self):
TestTransformationMixin.afterSetUp(self)
BaseTestUnitConversion.afterSetUp(self)
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
""" """
""" """
return ('erp5_base','erp5_pdm', 'erp5_trade', 'erp5_mrp',) return ('erp5_base','erp5_pdm', 'erp5_trade', 'erp5_mrp', 'erp5_apparel',
'erp5_dummy_movement', 'erp5_project')
def test_01_getAggregatedAmountListSimple(self): def test_01_getAggregatedAmountListSimple(self):
""" """
...@@ -213,6 +225,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -213,6 +225,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
variation_base_category_list = self.swimsuit_variation_base_category_list variation_base_category_list = self.swimsuit_variation_base_category_list
) )
transformation.setResourceValue(swimsuit) transformation.setResourceValue(swimsuit)
transaction.commit()
fabric = self.createResource( fabric = self.createResource(
'Fabric', 'Fabric',
...@@ -284,6 +297,11 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -284,6 +297,11 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
self.assertEqual(swimsuit.getDefaultTransformationValue().getRelativeUrl(),
transformation.getRelativeUrl())
self.assertEqual(fabric.getDefaultTransformationValue(), None)
self.assertEqual(button.getDefaultTransformationValue(), None)
# Swimming Suit does not use ALL categories in Size category. # Swimming Suit does not use ALL categories in Size category.
# As a result, transformation lines should restrict their dimensions, # As a result, transformation lines should restrict their dimensions,
# using the range induced by the resource, instead of naively # using the range induced by the resource, instead of naively
...@@ -325,8 +343,40 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): ...@@ -325,8 +343,40 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
self.fail("Invalid Resource: %s" % resource) self.fail("Invalid Resource: %s" % resource)
n += 1 n += 1
for size in self.size_category_list:
for colour in self.colour_category_list:
self.makeMovement(swimsuit_quantity, swimsuit, size, colour)
transaction.commit()
self.tic()
inv = self.getSimulationTool().getInventoryList(
node_uid=self.node.getUid(),
transformed_resource=[fabric.getRelativeUrl(),
button.getRelativeUrl(),
"operation/sewing"],
)
self.assertEquals(len(inv),
len(transformation) * len(self.size_category_list) \
* len(self.colour_category_list))
return
# XXX (will be expanded) # XXX (will be expanded)
for i, size in enumerate(self.size_category_list):
for colour in self.colour_category_list:
variation_text = '\n'.join([colour, size])
inv = self.getSimulationTool().getInventoryList(
node_uid=self.mirror_node.getUid(),
transformed_resource=[fabric.getRelativeUrl(),
button.getRelativeUrl(),
"operation/sewing"],
variation_text=variation_text,
)
import pdb; pdb.set_trace()
def test_resourceIsNotAcquiredOnTransformationLines(self): def test_resourceIsNotAcquiredOnTransformationLines(self):
''' '''
We don't want resource define on transformation to be acquired on 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