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
...@@ -56,7 +56,7 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -56,7 +56,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
def createOrganisation(self,title=None): def createOrganisation(self,title=None):
organisation_portal_type = 'Organisation' organisation_portal_type = 'Organisation'
portal = self.getPortal() portal = self.getPortal()
organisation_module = portal.getDefaultModule( \ organisation_module = portal.getDefaultModule( \
portal_type=organisation_portal_type) portal_type=organisation_portal_type)
organisation = organisation_module.newContent( \ organisation = organisation_module.newContent( \
...@@ -64,8 +64,9 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -64,8 +64,9 @@ class TestItemMixin(TestSaleInvoiceMixin):
if title is None: if title is None:
organisation.edit(title='organisation%s' % organisation.getId()) organisation.edit(title='organisation%s' % organisation.getId())
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,13 +135,15 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -136,13 +135,15 @@ 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(
title = "Packing List Line" title = "Packing List Line"
) )
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
...@@ -150,16 +151,16 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -150,16 +151,16 @@ class TestItemMixin(TestSaleInvoiceMixin):
item = item_module.newContent(portal_type=self.item_portal_type) item = item_module.newContent(portal_type=self.item_portal_type)
item.setResourceValue(resource) item.setResourceValue(resource)
sequence.edit(item_list=[item]) sequence.edit(item_list=[item])
def stepOrderLineSetAggregationList(self, sequence=None, def stepOrderLineSetAggregationList(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" Aggregate Items """ """ Aggregate Items """
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
item_list = sequence.get('item_list') item_list = sequence.get('item_list')
order_line.setAggregateValueList(item_list) order_line.setAggregateValueList(item_list)
def stepCheckOrderLineAggregate(self, sequence=None, def stepCheckOrderLineAggregate(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
""" Check items """ """ Check items """
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
...@@ -190,10 +191,10 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -190,10 +191,10 @@ class TestItemMixin(TestSaleInvoiceMixin):
""" Check items """ """ Check items """
item_list = sequence.get('item_list') item_list = sequence.get('item_list')
self.assertEquals(len(line.getAggregateList()),1) self.assertEquals(len(line.getAggregateList()),1)
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',
...@@ -304,7 +305,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -304,7 +305,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
'quantity': 10.0, 'quantity': 10.0,
'variation_category_list':['size/product_module/1/2'], 'variation_category_list':['size/product_module/1/2'],
}, },
{ 'listbox_key': '002', { 'listbox_key': '002',
'title': 'Lot C', 'title': 'Lot C',
'reference': '20_05_09_LC', 'reference': '20_05_09_LC',
'quantity': 15.0, 'quantity': 15.0,
...@@ -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)
...@@ -332,22 +333,22 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -332,22 +333,22 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
self.assertEquals(movement_cell_list[i].getAggregateTitle(), self.assertEquals(movement_cell_list[i].getAggregateTitle(),
listbox[i]['title']) listbox[i]['title'])
def test_04_CreateItemsFromPackingListLineWithVariationDefined( def test_04_CreateItemsFromPackingListLineWithVariationDefined(
self,sequence=None,title=None,quiet=quiet, run=run_all_test): self,sequence=None,title=None,quiet=quiet, run=run_all_test):
""" """
""" """
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',
...@@ -368,7 +369,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -368,7 +369,7 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
'quantity': 20.0, 'quantity': 20.0,
'variation_category_list':['size/product_module/2/1'], 'variation_category_list':['size/product_module/2/1'],
}, },
{ 'listbox_key': '001', { 'listbox_key': '001',
'title': 'Lot C2', 'title': 'Lot C2',
'reference': '25_05_09_LC2', 'reference': '25_05_09_LC2',
'quantity': 15.0, 'quantity': 15.0,
...@@ -376,34 +377,34 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -376,34 +377,34 @@ 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(),
listbox[i]['title']) listbox[i]['title'])
def test_05_CreateItemsFromPackingListLineWithNotVariatedResource( def test_05_CreateItemsFromPackingListLineWithNotVariatedResource(
self,sequence=None,title=None,quiet=quiet, run=run_all_test): self,sequence=None,title=None,quiet=quiet, run=run_all_test):
""" """
""" """
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',
...@@ -416,14 +417,14 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) : ...@@ -416,14 +417,14 @@ class TestItem(TestItemMixin, ERP5TypeTestCase) :
'reference': '25_05_09_LB3', 'reference': '25_05_09_LB3',
'quantity': 5.0, 'quantity': 5.0,
}, },
{ 'listbox_key': '002', { 'listbox_key': '002',
'title': 'Lot C3', 'title': 'Lot C3',
'reference': '25_05_09_LC3', 'reference': '25_05_09_LC3',
'quantity': 15.0, 'quantity': 15.0,
}, },
) )
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.
""" """
...@@ -583,8 +585,7 @@ class TestItemScripts(ERP5TypeTestCase): ...@@ -583,8 +585,7 @@ class TestItemScripts(ERP5TypeTestCase):
['Small', 'size/small']], ['Small', 'size/small']],
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