Commit 31666ee6 authored by Yusei Tahara's avatar Yusei Tahara

Add a test about checking quantity unit behavior on movement. Quantity unit...

Add a test about checking quantity unit behavior on movement. Quantity unit set to movement must not be changed by changing default quantity unit on resource. This test will fail as expected.
parent 30374e31
......@@ -33,7 +33,7 @@ from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from DateTime import DateTime
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestResource(ERP5TypeTestCase):
"""
......@@ -1115,6 +1115,84 @@ class TestResource(ERP5TypeTestCase):
self.assertEquals(resource.getInternalSupplyLineDestinationReference(),
'test_destination_reference_on_internal_supply_line')
def testQuantityUnitOnMovement(self):
"""Make sure that changing default quantity unit on resource does not
affect to movement.
In this test, always use Base.edit method. Because Base.edit is
used when real user edit document through edit form.
"""
# Set up quantity unit categories
# weight
quantity_unit_category_value = self.portal.portal_categories.quantity_unit
quantity_unit_weight = quantity_unit_category_value._getOb('weight', None)
if quantity_unit_weight is None:
quantity_unit_weight = quantity_unit_category_value.newContent(
id='weight', portal_type='Category')
quantity_unit_gram = quantity_unit_weight._getOb('gram', None)
if quantity_unit_gram is None:
quantity_unit_gram = quantity_unit_weight.newContent(
portal_type='Category', id='gram')
# volume
quantity_unit_volume = quantity_unit_category_value._getOb('volume', None)
if quantity_unit_volume is None:
quantity_unit_volume = quantity_unit_category_value.newContent(
id='volume', portal_type='Category')
quantity_unit_liter = quantity_unit_volume._getOb('liter', None)
if quantity_unit_liter is None:
quantity_unit_liter = quantity_unit_volume.newContent(
portal_type='Category', id='liter')
self.commit()
# Create resource
resource_value = self.portal.getDefaultModule(
self.product_portal_type).newContent(portal_type=self.product_portal_type)
resource_value.edit(quantity_unit_value_list=(
quantity_unit_gram, quantity_unit_liter))
self.commit()
self.assertEqual(resource_value.getDefaultQuantityUnitValue(),
quantity_unit_gram)
# Create sale order line
sale_order = self.portal.getDefaultModule('Sale Order').newContent(
portal_type='Sale Order')
sale_order_line = sale_order.newContent(
portal_type=self.sale_order_line_portal_type)
self.commit()
# Set resource to movement
sale_order_line.edit(resource_value=resource_value)
self.commit()
self.assertEqual(sale_order_line.getQuantityUnitValue(),
quantity_unit_gram)
# Select different quantity unit
sale_order_line.edit(quantity_unit_value=quantity_unit_liter)
self.commit()
self.assertEqual(sale_order_line.getQuantityUnitValue(),
quantity_unit_liter)
# Select empty(no quantity unit)
sale_order_line.edit(quantity_unit_value=None)
self.commit()
# Select default quantity unit again
sale_order_line.edit(quantity_unit_value=quantity_unit_gram)
self.commit()
self.assertEqual(sale_order_line.getQuantityUnitValue(),
quantity_unit_gram)
# Change default quantity unit on resource
# Now liter is default quantity unit.
resource_value.edit(quantity_unit_value_list=(
quantity_unit_liter, quantity_unit_gram))
self.commit()
# Check existing movement again and make sure that quantity
# unit is not changed.
expectedFailure(self.assertEqual)(
sale_order_line.getQuantityUnitValue(),
quantity_unit_gram)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestResource))
......
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