Commit 68b422c2 authored by Sebastien Robin's avatar Sebastien Robin

make the test with variated inventory working


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4625 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21c678d6
...@@ -62,10 +62,11 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -62,10 +62,11 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
run_all_test = 0 run_all_test = 0
inventory_portal_type = 'Inventory' inventory_portal_type = 'Inventory'
inventory_line_portal_type = 'Inventory Line' inventory_line_portal_type = 'Inventory Line'
inventory_cell_portal_type = 'Inventory Line' inventory_cell_portal_type = 'Inventory Cell'
first_date_string = '2005/12/09' # First Inventory first_date_string = '2005/12/09' # First Inventory
second_date_string = '2005/12/29' # Next Inventory second_date_string = '2005/12/29' # Next Inventory
view_stock_date = '2005/12/31' # The day where we are looking for stock view_stock_date = '2005/12/31' # The day where we are looking for stock
size_list = ['Child/32','Child/34']
def getInventoryModule(self): def getInventoryModule(self):
return getattr(self.getPortal(), 'inventory_module',None) return getattr(self.getPortal(), 'inventory_module',None)
...@@ -73,26 +74,33 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -73,26 +74,33 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
def stepCommit(self,**kw): def stepCommit(self,**kw):
get_transaction().commit() get_transaction().commit()
def createNotVariatedInventory(self, start_date=None,quantity=None, def createInventory(self, start_date=None,
sequence=None,**kw): sequence=None,**kw):
""" """
We will put default values for an inventory We will put default values for an inventory
""" """
portal = self.getPortal() portal = self.getPortal()
resource = sequence.get('resource_list')[0]
organisation = sequence.get('organisation') organisation = sequence.get('organisation')
inventory = self.getInventoryModule().newContent() inventory = self.getInventoryModule().newContent()
inventory.edit(start_date=start_date, inventory.edit(start_date=start_date,
destination_value=organisation) destination_value=organisation)
inventory_list = sequence.get('inventory_list',[])
inventory_list.append(inventory)
sequence.edit(inventory_list=inventory_list)
return inventory
def createNotVariatedInventoryLine(self, quantity=None,
sequence=None,**kw):
"""
We will put default values for an inventory
"""
portal = self.getPortal()
inventory = sequence.get('inventory_list')[-1]
resource = sequence.get('resource_list')[-1]
inventory_line = inventory.newContent( inventory_line = inventory.newContent(
portal_type=self.inventory_line_portal_type) portal_type=self.inventory_line_portal_type)
inventory_line.edit(inventory=quantity, inventory_line.edit(inventory=quantity,
resource_value = resource, resource_value = resource)
destination_value=organisation)
LOG('create inventory with start_date',0,start_date)
LOG('inventory.getStopDate',0,inventory.getStopDate())
LOG('inventory_line.getStopDate',0,inventory_line.getStopDate())
LOG('inventory_line.showDict()',0,inventory_line.showDict())
return inventory return inventory
def stepCreateFirstNotVariatedInventory(self, sequence=None, sequence_list=None, \ def stepCreateFirstNotVariatedInventory(self, sequence=None, sequence_list=None, \
...@@ -104,7 +112,8 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -104,7 +112,8 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
date = DateTime(self.first_date_string) date = DateTime(self.first_date_string)
LOG('stepCreateFirstNotVariatedInventory, date',0,date) LOG('stepCreateFirstNotVariatedInventory, date',0,date)
quantity=self.default_quantity quantity=self.default_quantity
self.createNotVariatedInventory(start_date=date,sequence=sequence, self.createInventory(start_date=date,sequence=sequence)
self.createNotVariatedInventoryLine(sequence=sequence,
quantity=quantity) quantity=quantity)
def stepCreateSecondNotVariatedInventory(self, sequence=None, sequence_list=None, \ def stepCreateSecondNotVariatedInventory(self, sequence=None, sequence_list=None, \
...@@ -115,7 +124,8 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -115,7 +124,8 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
portal = self.getPortal() portal = self.getPortal()
date = DateTime(self.second_date_string) date = DateTime(self.second_date_string)
quantity=self.default_quantity - 2 quantity=self.default_quantity - 2
self.createNotVariatedInventory(start_date=date,sequence=sequence, self.createInventory(start_date=date,sequence=sequence)
self.createNotVariatedInventoryLine(sequence=sequence,
quantity=quantity) quantity=quantity)
def stepCheckFirstNotVariatedInventory(self, start_date=None,quantity=None, def stepCheckFirstNotVariatedInventory(self, start_date=None,quantity=None,
...@@ -123,9 +133,6 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -123,9 +133,6 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
node_uid = sequence.get('organisation').getUid() node_uid = sequence.get('organisation').getUid()
resource_url = sequence.get('resource').getRelativeUrl() resource_url = sequence.get('resource').getRelativeUrl()
date = DateTime(self.view_stock_date) date = DateTime(self.view_stock_date)
LOG('sql src',0,self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url,
to_date=date,src__=1))
quantity = self.getSimulationTool().getInventory(node_uid=node_uid, quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url, resource=resource_url,
to_date=date) to_date=date)
...@@ -136,6 +143,9 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -136,6 +143,9 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
node_uid = sequence.get('organisation').getUid() node_uid = sequence.get('organisation').getUid()
resource_url = sequence.get('resource').getRelativeUrl() resource_url = sequence.get('resource').getRelativeUrl()
date = DateTime(self.view_stock_date) date = DateTime(self.view_stock_date)
LOG('CheckSecondNotVariatedInventory',0, self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url,
to_date=date,src__=1))
quantity = self.getSimulationTool().getInventory(node_uid=node_uid, quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url, resource=resource_url,
to_date=date) to_date=date)
...@@ -151,12 +161,11 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -151,12 +161,11 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
if not run: return if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test with a simply order without cell # Test with a simple inventory without cell
sequence_string = 'CreateNotVariatedResource \ sequence_string = 'CreateNotVariatedResource \
CreateOrganisation \ CreateOrganisation \
CreateFirstNotVariatedInventory \ CreateFirstNotVariatedInventory \
Tic \ Tic \
Commit \
CheckFirstNotVariatedInventory \ CheckFirstNotVariatedInventory \
CreateSecondNotVariatedInventory \ CreateSecondNotVariatedInventory \
Tic \ Tic \
...@@ -165,54 +174,67 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -165,54 +174,67 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
sequence_list.play(self) sequence_list.play(self)
def createVariatedInventory(self, sequence=None, sequence_list=None, \ def createVariatedInventoryLine(self, sequence=None, sequence_list=None, \
**kw): start_date=None,quantity=None,**kw):
""" """
We will put default values for an inventory We will put default values for an inventory
""" """
portal = self.getPortal() portal = self.getPortal()
inventory = self.createVariatedInventory(date=date,sequence=sequence) inventory = sequence.get('inventory_list')[-1]
inventory_line = self.objectValues( resource = sequence.get('resource_list')[-1]
portal_type=self.inventory_line_portal_type)[0] inventory_line = inventory.newContent(
order_line = sequence.get('order_line') portal_type=self.inventory_line_portal_type)
# XXX XXX XXX To be updated inventory_line.edit(resource_value = resource)
resource = sequence.get('resource')
resource_vcl = list(resource.getVariationCategoryList( resource_vcl = list(resource.getVariationCategoryList(
omit_individual_variation=0)) omit_individual_variation=1,omit_option_base_category=1))
resource_vcl.sort() resource_vcl.sort()
order_line.setVariationCategoryList(resource_vcl) self.assertEquals(len(resource_vcl),2)
order_line = sequence.get('order_line') LOG('resource_vcl',0,resource_vcl)
inventory_line.setVariationCategoryList(resource_vcl)
base_id = 'movement' base_id = 'movement'
cell_key_list = list(order_line.getCellKeyList(base_id=base_id)) cell_key_list = list(inventory_line.getCellKeyList(base_id=base_id))
cell_key_list.sort() cell_key_list.sort()
price = 100 price = 100
quantity = 200
for cell_key in cell_key_list: for cell_key in cell_key_list:
cell = order_line.newCell(base_id=base_id, \ cell = inventory_line.newCell(base_id=base_id, \
portal_type=self.cell_portal_type, *cell_key) portal_type=self.inventory_cell_portal_type, *cell_key)
cell.edit(mapped_value_property_list=['price','quantity'], cell.edit(mapped_value_property_list=['price','inventory'],
price=price, quantity=quantity, price=price, inventory=quantity,
predicate_category_list=cell_key, predicate_category_list=cell_key,
variation_category_list=cell_key) variation_category_list=cell_key)
price += 1 price += 1
quantity += 1 quantity += 1
def stepCreateVariatedInventory(self, sequence=None, sequence_list=None, \ def stepCreateFirstVariatedInventory(self, sequence=None, sequence_list=None, \
**kw): **kw):
""" """
We will put default values for an inventory We will put default values for an inventory
""" """
portal = self.getPortal() portal = self.getPortal()
date = DateTime(self.first_date_string) date = DateTime(self.first_date_string)
inventory = self.createVariatedInventory(date=date,sequence=sequence) inventory = self.createInventory(start_date=date,sequence=sequence)
inventory_line = 'a' quantity = self.default_quantity
inventory = self.createVariatedInventoryLine(start_date=date,
sequence=sequence, quantity=quantity)
def stepCreateSecondVariatedInventory(self, sequence=None, sequence_list=None, \
**kw):
"""
We will put default values for an inventory
"""
portal = self.getPortal()
date = DateTime(self.second_date_string)
inventory = self.createInventory(start_date=date,sequence=sequence)
quantity = self.default_quantity - 10
inventory = self.createVariatedInventoryLine(start_date=date,
sequence=sequence, quantity=quantity)
def createVariatedInventory(self, start_date=None,quantity=None, def createVariatedInventory(self, start_date=None,quantity=None,
sequence=None,**kw): sequence=None,**kw):
""" """
We will put default values for an inventory We will put default values for an inventory
""" """
inventory = self.createNotVariatedInventory() inventory = self.createNotVariatedInventory(sequence=sequence,start_date=start_date)
resource = sequence.get('resource_list')[0] resource = sequence.get('resource_list')[0]
organisation = sequence.get('organisation') organisation = sequence.get('organisation')
inventory = self.getInventoryModule().newContent() inventory = self.getInventoryModule().newContent()
...@@ -224,15 +246,61 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase): ...@@ -224,15 +246,61 @@ class TestInventoryModule(TestOrderMixin,ERP5TypeTestCase):
resource_value = resource, resource_value = resource,
destination_value=organisation) destination_value=organisation)
def test_02_VariatedInventory(self, quiet=0, run=run_all_test): def stepCheckFirstVariatedInventory(self, start_date=None,quantity=None,
sequence=None,**kw):
node_uid = sequence.get('organisation').getUid()
resource_url = sequence.get('resource').getRelativeUrl()
date = DateTime(self.view_stock_date)
total_quantity = 99 + 100
quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url,
to_date=date)
self.assertEquals(total_quantity,quantity)
variation_text = 'size/Child/32'
total_quantity = 99
quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url,
variation_text=variation_text,
to_date=date)
self.assertEquals(total_quantity,quantity)
def stepCheckSecondVariatedInventory(self, start_date=None,quantity=None,
sequence=None,**kw):
node_uid = sequence.get('organisation').getUid()
resource_url = sequence.get('resource').getRelativeUrl()
date = DateTime(self.view_stock_date)
total_quantity = 89 + 90
quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url,
to_date=date)
self.assertEquals(total_quantity,quantity)
variation_text = 'size/Child/32'
total_quantity = 89
LOG('CheckSecondVariatedInventory',0, self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url,variation_text=variation_text,
to_date=date,src__=1))
quantity = self.getSimulationTool().getInventory(node_uid=node_uid,
resource=resource_url,
variation_text=variation_text,
to_date=date)
self.assertEquals(total_quantity,quantity)
def test_02_VariatedInventory(self, quiet=0, run=1):
""" """
Same thing as test_01 with variation Same thing as test_01 with variation
""" """
if not run: return if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test with a simply order without cell # Test with a variated inventory
sequence_string = '' sequence_string = 'CreateVariatedResource \
CreateOrganisation \
CreateFirstVariatedInventory \
Tic \
CheckFirstVariatedInventory \
CreateSecondVariatedInventory \
Tic \
CheckSecondVariatedInventory'
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
......
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