Commit 95349249 authored by Romain Courteaud's avatar Romain Courteaud

Associate the constraint's propertysheet of Inventory, as it is not associated

by default anymore.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20486 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dbf20ffa
...@@ -44,6 +44,7 @@ from Products.ERP5.Document.OrderRule import OrderRule ...@@ -44,6 +44,7 @@ from Products.ERP5.Document.OrderRule import OrderRule
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.Base import _aq_reset
class InventoryAPITestCase(ERP5TypeTestCase): class InventoryAPITestCase(ERP5TypeTestCase):
"""Base class for Inventory API Tests {{{ """Base class for Inventory API Tests {{{
...@@ -2010,51 +2011,75 @@ class TestInventoryDocument(InventoryAPITestCase): ...@@ -2010,51 +2011,75 @@ class TestInventoryDocument(InventoryAPITestCase):
does not allow such things does not allow such things
""" """
portal = self.getPortal() portal = self.getPortal()
inventory_module = portal.getDefaultModule(portal_type='Inventory')
inventory = inventory_module.newContent(portal_type='Inventory')
date = self.DUPLICATE_INVENTORY_DATE
inventory.edit(destination_value=self.node,
destination_section_value=self.section,
start_date=date)
inventory_line = inventory.newContent(
resource_value = self.resource,
quantity = 1)
self.workflow_tool = portal.portal_workflow
workflow_id = 'inventory_workflow'
transition_id = 'deliver_action'
workflow_id= 'inventory_workflow'
self.workflow_tool.doActionFor(inventory, transition_id,
wf_id=workflow_id)
self.assertEquals('delivered', inventory.getSimulationState())
get_transaction().commit()
self.tic()
# We should detect the previous inventory and fails
new_inventory = inventory.Base_createCloneDocument(batch_mode=1)
self.assertRaises(ValidationFailed, self.workflow_tool.doActionFor,
new_inventory, transition_id, wf_id=workflow_id)
workflow_history = self.workflow_tool.getInfoFor(ob=new_inventory,
name='history', wf_id=workflow_id)
workflow_error_message = str(workflow_history[-1]['error_message'])
self.assertTrue(workflow_error_message.find('There is already an inventory')>=0)
# Add a case in order to check a bug when the other inventory at the
# same date does not change stock values
new_inventory = inventory.Base_createCloneDocument(batch_mode=1)
new_inventory.setStartDate(self.DUPLICATE_INVENTORY_DATE + 1)
self.workflow_tool.doActionFor(new_inventory, transition_id,
wf_id=workflow_id)
self.assertEquals('delivered', new_inventory.getSimulationState())
get_transaction().commit()
self.tic()
new_inventory = new_inventory.Base_createCloneDocument(batch_mode=1) portal_type_name = 'Inventory'
self.assertRaises(ValidationFailed, self.workflow_tool.doActionFor, property_sheet_name = 'InventoryConstraint'
new_inventory, transition_id, wf_id=workflow_id) # We set the property sheet on the portal type
workflow_history = self.workflow_tool.getInfoFor(ob=new_inventory, ti = self.getTypesTool().getTypeInfo(portal_type_name)
name='history', wf_id=workflow_id) ti.property_sheet_list = list(ti.property_sheet_list) +\
workflow_error_message = str(workflow_history[-1]['error_message']) [property_sheet_name]
self.assertTrue(workflow_error_message.find('There is already an inventory')>=0) # reset aq_dynamic cache
_aq_reset()
try:
inventory_module = portal.getDefaultModule(portal_type='Inventory')
inventory = inventory_module.newContent(portal_type='Inventory')
date = self.DUPLICATE_INVENTORY_DATE
inventory.edit(destination_value=self.node,
destination_section_value=self.section,
start_date=date)
inventory_line = inventory.newContent(
resource_value = self.resource,
quantity = 1)
self.workflow_tool = portal.portal_workflow
workflow_id = 'inventory_workflow'
transition_id = 'deliver_action'
workflow_id= 'inventory_workflow'
self.workflow_tool.doActionFor(inventory, transition_id,
wf_id=workflow_id)
self.assertEquals('delivered', inventory.getSimulationState())
get_transaction().commit()
self.tic()
# We should detect the previous inventory and fails
new_inventory = inventory.Base_createCloneDocument(batch_mode=1)
self.assertRaises(ValidationFailed, self.workflow_tool.doActionFor,
new_inventory, transition_id, wf_id=workflow_id)
workflow_history = self.workflow_tool.getInfoFor(ob=new_inventory,
name='history', wf_id=workflow_id)
workflow_error_message = str(workflow_history[-1]['error_message'])
self.assertTrue(workflow_error_message.find('There is already an inventory')>=0)
# Add a case in order to check a bug when the other inventory at the
# same date does not change stock values
new_inventory = inventory.Base_createCloneDocument(batch_mode=1)
new_inventory.setStartDate(self.DUPLICATE_INVENTORY_DATE + 1)
self.workflow_tool.doActionFor(new_inventory, transition_id,
wf_id=workflow_id)
self.assertEquals('delivered', new_inventory.getSimulationState())
get_transaction().commit()
self.tic()
new_inventory = new_inventory.Base_createCloneDocument(batch_mode=1)
self.assertRaises(ValidationFailed, self.workflow_tool.doActionFor,
new_inventory, transition_id, wf_id=workflow_id)
workflow_history = self.workflow_tool.getInfoFor(ob=new_inventory,
name='history', wf_id=workflow_id)
workflow_error_message = str(workflow_history[-1]['error_message'])
self.assertTrue(workflow_error_message.find('There is already an inventory')>=0)
finally:
# remove all property sheet we added to type informations
ttool = self.getTypesTool()
ti = ttool.getTypeInfo(portal_type_name)
ps_list = ti.property_sheet_list
psheet_list = [property_sheet_name]
for psheet in psheet_list:
if psheet in ps_list:
ps_list.remove(psheet)
ti.property_sheet_list = ps_list
get_transaction().commit()
_aq_reset()
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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