Commit 4b825f7d authored by Jérome Perrin's avatar Jérome Perrin

style changes

get_transaction -> transaction


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27275 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9c3c307c
...@@ -66,6 +66,7 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -66,6 +66,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
else: else:
organisation.edit(title=title) organisation.edit(title=title)
return organisation return organisation
def createNotVariatedResource(self,title=None): def createNotVariatedResource(self,title=None):
""" """
Create a resource with no variation Create a resource with no variation
...@@ -81,17 +82,16 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -81,17 +82,16 @@ class TestItemMixin(TestSaleInvoiceMixin):
required_aggregated_portal_type_list=['Item'] required_aggregated_portal_type_list=['Item']
) )
return resource return resource
def createVariatedResource(self,title=None): def createVariatedResource(self,title=None):
preference = self.portal.portal_preferences preference = self.portal.portal_preferences
portal_workflow = self.portal.portal_workflow portal_workflow = self.portal.portal_workflow
pref = preference.newContent(portal_type='System Preference') pref = preference.newContent(portal_type='System Preference')
pref.setPreferredProductIndividualVariationBaseCategoryList(['size']) pref.setPreferredProductIndividualVariationBaseCategoryList(['size'])
portal_workflow.doActionFor(pref, 'enable_action') portal_workflow.doActionFor(pref, 'enable_action')
get_transaction().commit() transaction.commit()
self.tic() self.tic()
# person = sequence.get('person')
portal = self.getPortal() portal = self.getPortal()
resource_portal_type = 'Product' resource_portal_type = 'Product'
resource_module = portal.getDefaultModule(resource_portal_type) resource_module = portal.getDefaultModule(resource_portal_type)
...@@ -112,9 +112,8 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -112,9 +112,8 @@ class TestItemMixin(TestSaleInvoiceMixin):
title = 'SizeVariation%s' % str(i) title = 'SizeVariation%s' % str(i)
) )
resource_list = []
resource_list.append(resource)
return resource return resource
def createPackingList(self,resource=None,organisation=None): def createPackingList(self,resource=None,organisation=None):
portal = self.getPortal() portal = self.getPortal()
packing_list_module = portal.getDefaultModule(portal_type='Purchase Packing List') packing_list_module = portal.getDefaultModule(portal_type='Purchase Packing List')
...@@ -136,6 +135,7 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -136,6 +135,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
destination_administration_value=organisation, destination_administration_value=organisation,
) )
return pac_list return pac_list
def createPackingListLine(self,packing_list=None,resource=None): def createPackingListLine(self,packing_list=None,resource=None):
packing_list_line = packing_list.newContent(portal_type='Purchase Packing List Line') packing_list_line = packing_list.newContent(portal_type='Purchase Packing List Line')
packing_list_line.edit( packing_list_line.edit(
...@@ -143,6 +143,7 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -143,6 +143,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
) )
packing_list_line.setResourceValue(resource) packing_list_line.setResourceValue(resource)
return packing_list_line return packing_list_line
def stepCreateItemList(self, sequence=None, sequence_list=None, **kw): def stepCreateItemList(self, sequence=None, sequence_list=None, **kw):
""" Create some items """ """ Create some items """
item_module = self.getPortal().item_module item_module = self.getPortal().item_module
...@@ -193,7 +194,7 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -193,7 +194,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
self.failUnless(item_list[0] in line.getAggregateValueList()) self.failUnless(item_list[0] in line.getAggregateValueList())
class TestItem(TestItemMixin, ERP5TypeTestCase) : class TestItem(TestItemMixin, ERP5TypeTestCase):
run_all_test = 1 run_all_test = 1
quiet = 0 quiet = 0
...@@ -282,14 +283,14 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -282,14 +283,14 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
""" """
if not run: return if not run: return
organisation = self.createOrganisation(title='Organisation I') organisation = self.createOrganisation(title='Organisation I')
get_transaction().commit() transaction.commit()
self.tic() self.tic()
resource = self.createVariatedResource() resource = self.createVariatedResource()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
packing_list = self.createPackingList(resource=resource,organisation=organisation) packing_list = self.createPackingList(resource=resource,organisation=organisation)
packing_list_line= self.createPackingListLine(packing_list=packing_list,resource=resource) packing_list_line= self.createPackingListLine(packing_list=packing_list,resource=resource)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
# create a listbox # create a listbox
listbox = ({ 'listbox_key': '000', listbox = ({ 'listbox_key': '000',
...@@ -312,7 +313,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -312,7 +313,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
}, },
) )
packing_list_line.DeliveryLine_createItemList(listbox=listbox) packing_list_line.DeliveryLine_createItemList(listbox=listbox)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
self.assertEquals( self.assertEquals(
len([x.getObject() for x in self.portal.portal_catalog(portal_type='Item',title='Lot A')]),1) len([x.getObject() for x in self.portal.portal_catalog(portal_type='Item',title='Lot A')]),1)
...@@ -339,15 +340,15 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -339,15 +340,15 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
""" """
if not run: return if not run: return
organisation = self.createOrganisation(title='Organisation II') organisation = self.createOrganisation(title='Organisation II')
get_transaction().commit() transaction.commit()
self.tic() self.tic()
resource = self.createVariatedResource() resource = self.createVariatedResource()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
packing_list = self.createPackingList(resource=resource,organisation=organisation) packing_list = self.createPackingList(resource=resource,organisation=organisation)
packing_list_line= self.createPackingListLine(packing_list=packing_list,resource=resource) packing_list_line= self.createPackingListLine(packing_list=packing_list,resource=resource)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
# create a listbox # create a listbox
listbox = ({ 'listbox_key': '000', listbox = ({ 'listbox_key': '000',
...@@ -376,14 +377,14 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -376,14 +377,14 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
}, },
) )
packing_list_line.DeliveryLine_createItemList(listbox=listbox) packing_list_line.DeliveryLine_createItemList(listbox=listbox)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
self.assertEquals(packing_list_line.getQuantity(),35.0) self.assertEquals(packing_list_line.getQuantity(),35.0)
self.assertEquals(packing_list_line.getVariationCategoryList(), self.assertEquals(packing_list_line.getVariationCategoryList(),
['size/product_module/2/1','size/product_module/2/2']) ['size/product_module/2/1','size/product_module/2/2'])
movement_cell_list = packing_list_line.contentValues( movement_cell_list = packing_list_line.contentValues(
portal_type='Purchase Packing List Cell') portal_type='Purchase Packing List Cell')
for i in range(0,len(movement_cell_list)): for i in range(0, len(movement_cell_list)):
self.assertEquals(movement_cell_list[i].getQuantity(), self.assertEquals(movement_cell_list[i].getQuantity(),
listbox[i]['quantity']) listbox[i]['quantity'])
self.assertEquals(movement_cell_list[i].getAggregateTitle(), self.assertEquals(movement_cell_list[i].getAggregateTitle(),
...@@ -395,15 +396,15 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -395,15 +396,15 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
""" """
if not run: return if not run: return
organisation = self.createOrganisation(title='Organisation III') organisation = self.createOrganisation(title='Organisation III')
get_transaction().commit() transaction.commit()
self.tic() self.tic()
resource = self.createNotVariatedResource() resource = self.createNotVariatedResource()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
packing_list = self.createPackingList(resource=resource,organisation=organisation) packing_list = self.createPackingList(resource=resource,organisation=organisation)
packing_list_line= self.createPackingListLine(packing_list=packing_list,resource=resource) packing_list_line= self.createPackingListLine(packing_list=packing_list,resource=resource)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
# create a listbox # create a listbox
listbox = ({ 'listbox_key': '000', listbox = ({ 'listbox_key': '000',
...@@ -423,7 +424,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -423,7 +424,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
}, },
) )
packing_list_line.DeliveryLine_createItemList(listbox=listbox) packing_list_line.DeliveryLine_createItemList(listbox=listbox)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
self.assertEquals( self.assertEquals(
len([x.getObject() for x in self.portal.portal_catalog(portal_type='Item',title='Lot A3')]),1) len([x.getObject() for x in self.portal.portal_catalog(portal_type='Item',title='Lot A3')]),1)
...@@ -439,6 +440,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -439,6 +440,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
portal_type='Purchase Packing List Cell') portal_type='Purchase Packing List Cell')
self.assertEquals(movement_cell_list,[]) self.assertEquals(movement_cell_list,[])
class TestItemScripts(ERP5TypeTestCase): class TestItemScripts(ERP5TypeTestCase):
"""Test scripts from erp5_item. """Test scripts from erp5_item.
""" """
...@@ -584,7 +586,6 @@ class TestItemScripts(ERP5TypeTestCase): ...@@ -584,7 +586,6 @@ class TestItemScripts(ERP5TypeTestCase):
self.item.Item_getVariationRangeCategoryItemList()) self.item.Item_getVariationRangeCategoryItemList())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestItem)) suite.addTest(unittest.makeSuite(TestItem))
......
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