Commit 2dc55a54 authored by Nicolas Dumazet's avatar Nicolas Dumazet

style/spacing/naming/indentation only.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41481 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bcf7b673
...@@ -51,24 +51,24 @@ class TestApparelModel(ERP5TypeTestCase): ...@@ -51,24 +51,24 @@ class TestApparelModel(ERP5TypeTestCase):
def createCategories(self): def createCategories(self):
"""Create the categories for our test. """ """Create the categories for our test. """
# create categories # create categories
for cat_string in self.getNeededCategoryList() : for cat_string in self.getNeededCategoryList():
base_cat = cat_string.split("/")[0] base_cat = cat_string.split("/")[0]
# if base_cat not exist, create it # if base_cat not exist, create it
if getattr(self.getPortal().portal_categories, base_cat, None) == None: if getattr(self.getPortal().portal_categories, base_cat, None) is None:
self.getPortal().portal_categories.newContent(\ self.getPortal().portal_categories.newContent(
portal_type='Base Category', portal_type='Base Category',
id=base_cat) id=base_cat)
path = self.getPortal().portal_categories[base_cat] path = self.getPortal().portal_categories[base_cat]
for cat in cat_string.split("/")[1:] : for cat_id in cat_string.split("/")[1:]:
if not cat in path.objectIds() : if not cat_id in path.objectIds():
path = path.newContent( path = path.newContent(
portal_type='Category', portal_type='Category',
id=cat, id=cat_id,
title=cat.replace('_', ' ').title(),) title=cat_id.title())
else: else:
path = path[cat] path = path[cat_id]
# check categories have been created # check categories have been created
for cat_string in self.getNeededCategoryList() : for cat_string in self.getNeededCategoryList():
self.assertNotEquals(None, self.assertNotEquals(None,
self.getCategoryTool().restrictedTraverse(cat_string), self.getCategoryTool().restrictedTraverse(cat_string),
cat_string) cat_string)
...@@ -84,72 +84,87 @@ class TestApparelModel(ERP5TypeTestCase): ...@@ -84,72 +84,87 @@ class TestApparelModel(ERP5TypeTestCase):
Check that it's possible to copy composition from a model, and that cells Check that it's possible to copy composition from a model, and that cells
are well created. are well created.
''' '''
portal = self.getPortal()
# defin an apparel fabric # defin an apparel fabric
apparel_fabric_module = self.getPortal().getDefaultModule('Apparel Fabric') apparel_fabric_module = portal.getDefaultModule('Apparel Fabric')
apparel_fabric = apparel_fabric_module.newContent(portal_type=\ apparel_fabric = apparel_fabric_module.newContent(
'Apparel Fabric') portal_type = 'Apparel Fabric')
apparel_fabric.setCategoryList(('composition/acrylique', 'composition/elasthane')) apparel_fabric.setCategoryList(
apparel_fabric.updateCellRange(base_id='composition') ('composition/acrylique',
'composition/elasthane'))
apparel_fabric.updateCellRange(base_id = 'composition')
# create composition cells # create composition cells
apparel_fabric.newCell('composition/acrylique', apparel_fabric.newCell(
base_id='composition', 'composition/acrylique',
portal_type='Mapped Value', base_id = 'composition',
quantity = 0.88) portal_type = 'Mapped Value',
apparel_fabric.newCell('composition/elasthane', quantity = 0.88)
base_id='composition', apparel_fabric.newCell(
portal_type='Mapped Value', 'composition/elasthane',
quantity = 0.12) base_id ='composition',
portal_type = 'Mapped Value',
quantity = 0.12)
# add some color variations # add some color variations
fabric_color1 = apparel_fabric.newContent(portal_type='Apparel Fabric Colour Variation', fabric_color1 = apparel_fabric.newContent(
title='Bleu ciel') portal_type = 'Apparel Fabric Colour Variation',
fabric_color2 = apparel_fabric.newContent(portal_type='Apparel Fabric Colour Variation', title = 'Bleu ciel')
title='Volcano') fabric_color2 = apparel_fabric.newContent(
portal_type = 'Apparel Fabric Colour Variation',
title = 'Volcano')
# create an Apparel Colour Range # create an Apparel Colour Range
apparel_colour_range_module = self.getPortal().getDefaultModule(\ apparel_colour_range_module = portal.getDefaultModule('Apparel Colour Range')
'Apparel Colour Range') apparel_colour_range = apparel_colour_range_module.newContent(
apparel_colour_range = apparel_colour_range_module.newContent(portal_type=\ portal_type = 'Apparel Colour Range')
'Apparel Colour Range') color1 = apparel_colour_range.newContent(
color1 = apparel_colour_range.newContent(title='Blue', title = 'Blue',
portal_type='Apparel Colour Range Variation') portal_type = 'Apparel Colour Range Variation')
color2 = apparel_colour_range.newContent(title='Red', color2 = apparel_colour_range.newContent(
portal_type='Apparel Colour Range Variation') title = 'Red',
portal_type = 'Apparel Colour Range Variation')
variation1 = color1.newContent(title='Ocean', int_index=2,
portal_type='Apparel Colour Range Variation Line') variation1 = color1.newContent(
variation2 = color1.newContent(title='Volcano', int_index=1, title = 'Ocean',
portal_type='Apparel Colour Range Variation Line') int_index = 2,
portal_type = 'Apparel Colour Range Variation Line')
variation2 = color1.newContent(
title = 'Volcano',
int_index = 1,
portal_type = 'Apparel Colour Range Variation Line')
variation1.setSpecialiseValue(fabric_color1) variation1.setSpecialiseValue(fabric_color1)
variation2.setSpecialiseValue(fabric_color2) variation2.setSpecialiseValue(fabric_color2)
# create an Apparel Model # create an Apparel Model
apparel_model_module = self.getPortal().getDefaultModule(\ apparel_model_module = portal.getDefaultModule('Apparel Model')
'Apparel Model')
apparel_model = apparel_model_module.newContent(portal_type='Apparel Model') apparel_model = apparel_model_module.newContent(portal_type='Apparel Model')
apparel_model.setSpecialiseValue(apparel_colour_range) apparel_model.setSpecialiseValue(apparel_colour_range)
apparel_model.ApparelModel_copyComposition() apparel_model.ApparelModel_copyComposition()
# check the cells have been copied # check the cells have been copied
self.assertEquals(len(apparel_model.contentValues(portal_type=\ cell_list = apparel_model.contentValues(portal_type = 'Mapped Value')
'Mapped Value')), 2) self.assertEquals(len(cell_list), 2)
self.assertNotEquals(apparel_model.getCell('composition/acrylique',
base_id='composition'), None) acrylique = apparel_model.getCell(
cell1 = apparel_model.getCell('composition/acrylique', 'composition/acrylique',
base_id='composition') base_id = 'composition')
self.assertEqual(cell1.getQuantity(), 0.88) self.assertNotEquals(acrylique, None)
self.assertNotEquals(apparel_model.getCell('composition/elasthane', self.assertEqual(acrylique.getQuantity(), 0.88)
base_id='composition'), None)
cell1 = apparel_model.getCell('composition/elasthane', elasthane = apparel_model.getCell(
base_id='composition') 'composition/elasthane',
self.assertEqual(cell1.getQuantity(), 0.12) base_id = 'composition')
self.assertNotEquals(elasthane, None)
self.assertEqual(elasthane.getQuantity(), 0.12)
# check indexes are present # check indexes are present
self.assertTrue(apparel_model.index.has_key('composition')) self.assertTrue(apparel_model.index.has_key('composition'))
self.assertTrue(apparel_model.index['composition'][0].has_key('composition/elasthane')) index = apparel_model.index['composition'][0]
self.assertTrue(apparel_model.index['composition'][0].has_key('composition/acrylique')) self.assertTrue(index.has_key('composition/elasthane'))
self.assertTrue(index.has_key('composition/acrylique'))
def test_checkCopyColourRangeVariation(self): def test_checkCopyColourRangeVariation(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