Commit 8352cf33 authored by Yusei Tahara's avatar Yusei Tahara

Add a test for product which is variated and have multiple quantity units.

parent d6d75962
...@@ -328,6 +328,15 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -328,6 +328,15 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
) )
sequence.edit(delivery_line_list=delivery_line_list) sequence.edit(delivery_line_list=delivery_line_list)
def stepCreateVariatedNonDefaultQuantityUnitPackingListLine(
self, sequence=None, sequence_list=None, **kw):
"""
Create a line not variated
"""
self.stepCreateVariatedPackingListLine(sequence, sequence_list, **kw)
delivery_line = sequence.get('delivery_line_list')[-1]
delivery_line.setQuantityUnitValue(self.portal.portal_categories.quantity_unit.unit.drum)
def stepDeliverPackingList(self, sequence=None, def stepDeliverPackingList(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
# Switch to "started" state # Switch to "started" state
...@@ -1778,6 +1787,20 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1778,6 +1787,20 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
self.checkVariatedInventory(variation_category_list=variation_category_list, self.checkVariatedInventory(variation_category_list=variation_category_list,
quantity=quantity,sequence=sequence) quantity=quantity,sequence=sequence)
def stepTestInitialVariatedNonDefaultQuantityUnitInventory(self, sequence=None, sequence_list=None, **kw):
"""
Test Inventory Module behavior
"""
resource = sequence.get('resource')
variation_category_list = sequence.get('variation_1')
quantity = 100
self.checkVariatedInventory(variation_category_list=variation_category_list,
quantity=quantity,sequence=sequence)
variation_category_list = sequence.get('variation_2')
quantity = 300
self.checkVariatedInventory(variation_category_list=variation_category_list,
quantity=quantity,sequence=sequence)
def stepTestVariatedInventoryAfterInventory(self, sequence=None, sequence_list=None, **kw): def stepTestVariatedInventoryAfterInventory(self, sequence=None, sequence_list=None, **kw):
""" """
Test Inventory Module behavior Test Inventory Module behavior
...@@ -1928,6 +1951,31 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1928,6 +1951,31 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
sequence_list.play(self) sequence_list.play(self)
def test_04_InventoryModuleWithVariationAndMultiQuantityUnit(self, quiet=0, run=run_all_test):
"""
Test InventoryModule behavior with product which has
variation and multiple quantity units.
"""
if not run: return
sequence_list = SequenceList()
sequence_string = 'stepCreateOrganisationsForModule \
stepCreateVariatedMultipleQuantityUnitResource \
stepTic \
stepCreatePackingListForModule \
stepTic \
stepCreateVariatedNonDefaultQuantityUnitPackingListLine \
stepTic \
stepDeliverPackingList \
stepTic \
stepTestInitialVariatedNonDefaultQuantityUnitInventory \
stepCreateSingleVariatedInventory \
stepTic \
stepTestVariatedInventoryAfterInventory \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestInventory)) suite.addTest(unittest.makeSuite(TestInventory))
......
...@@ -218,6 +218,52 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -218,6 +218,52 @@ class TestOrderMixin(SubcontentReindexingWrapper):
resource_list.append(resource) resource_list.append(resource)
sequence.edit( resource_list = resource_list ) sequence.edit( resource_list = resource_list )
def stepCreateVariatedMultipleQuantityUnitResource(self, sequence=None, sequence_list=None, **kw):
"""
Create a resource with variation and multiple quantity units
"""
# Extend quantity_unit category if needed
quantity_unit = self.portal.portal_categories.quantity_unit
if not 'unit' in quantity_unit.objectIds():
quantity_unit.newContent(id='unit')
if not 'drum' in quantity_unit.unit.objectIds():
quantity_unit.unit.newContent(id='drum', quantity=1)
if not 'mass' in quantity_unit.objectIds():
quantity_unit.newContent(id='mass')
if not 'kilogram' in quantity_unit.mass.objectIds():
quantity_unit.mass.newContent(id='kilogram', quantity=1)
# Extend metric_type category if needed
metric_type = self.portal.portal_categories.metric_type
if not 'unit' in metric_type.objectIds():
metric_type.newContent(id='unit')
if not 'mass' in metric_type.objectIds():
metric_type.newContent(id='mass')
# Create resource
self.stepCreateVariatedResource(sequence, sequence_list, **kw)
resource = sequence.get('resource')
# Extend resource portal type
resource_portal_type = getattr(self.portal.portal_types, resource.portal_type)
type_allowed_content_type_list = resource_portal_type.getTypeAllowedContentTypeList()
if not 'Measure' in type_allowed_content_type_list:
type_allowed_content_type_list.append('Measure')
resource_portal_type.setTypeAllowedContentTypeList(type_allowed_content_type_list)
# Set quantity units to product
resource.setQuantityUnitValueList([quantity_unit.mass.kilogram,
quantity_unit.unit.drum])
# Set measures to products
resource.newContent(portal_type='Measure',
metric_type_value=metric_type.mass,
default_metric_type=True,
quantity_unit_value=quantity_unit.mass.kilogram,
quantity=1)
resource.newContent(portal_type='Measure',
metric_type_value=metric_type.unit,
quantity_unit_value=quantity_unit.unit.drum,
quantity=0.01)
def stepCreateOrganisation(self, sequence=None, sequence_list=None, def stepCreateOrganisation(self, sequence=None, sequence_list=None,
title=None, **kw): title=None, **kw):
""" """
......
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