Commit b91cab5c authored by Aurel's avatar Aurel

check at build of bt that portal types properties exists in site, add test for this

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13886 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 79e755cb
...@@ -1509,8 +1509,17 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem): ...@@ -1509,8 +1509,17 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem):
class_property = 'allowed_content_types' class_property = 'allowed_content_types'
def build(self, context, **kw): def build(self, context, **kw):
types_tool = self.getPortalObject().portal_types
types_list = list(types_tool.objectIds())
for key in self._archive.keys(): for key in self._archive.keys():
portal_type, allowed_type = key.split(' | ') portal_type, allowed_type = key.split(' | ')
# check properties corresponds to what is defined in site
if not portal_type in types_list:
raise ValueError, "Portal Type %s not found in site" %(portal_type,)
ob = types_tool._getOb(portal_type)
prop_value = getattr(ob, self.class_property, ())
if not allowed_type in prop_value:
raise ValueError, "Property %s not found in portal type %s" %(allowed_type, portal_type)
if self._objects.has_key(portal_type): if self._objects.has_key(portal_type):
allowed_list = self._objects[portal_type] allowed_list = self._objects[portal_type]
allowed_list.append(allowed_type) allowed_list.append(allowed_type)
......
...@@ -404,6 +404,17 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -404,6 +404,17 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.failUnless(bt is not None) self.failUnless(bt is not None)
bt.getPortalTypesProperties() bt.getPortalTypesProperties()
def stepFillWrongPortalTypesFields(self, sequence=None, sequence_list=None, **kw):
"""
Fill portal types properties field in business template with wrong values
"""
bt = sequence.get('current_bt', None)
self.failUnless(bt is not None)
bt.getPortalTypesProperties()
bt_allowed_content_type_list = list(getattr(self, 'template_portal_type_allowed_content_type', []) or [])
bt_allowed_content_type_list.append("Geek Module | BusinessTemplate")
bt.setProperty('template_portal_type_allowed_content_type', bt_allowed_content_type_list)
# module # module
def stepCreateModuleAndObjects(self, sequence=None, sequence_list=None, **kw): def stepCreateModuleAndObjects(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -1964,6 +1975,14 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -1964,6 +1975,14 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
self.assertRaises(AttributeError, self.assertRaises(AttributeError,
template.build) template.build)
def stepCheckBuildWithBadPortalTypeFailed(self, sequence=None, sequence_list=None, **kw):
"""
Build Business Template
"""
template = sequence.get('current_bt')
self.assertRaises(ValueError,
template.build)
def stepBuildBusinessTemplate(self, sequence=None, sequence_list=None, **kw): def stepBuildBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
""" """
Build Business Template Build Business Template
...@@ -2252,6 +2271,31 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -2252,6 +2271,31 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def test_021_BusinessTemplateWithPortalTypesAdnWrongValues(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test Business Template With Portal Types and Bad Values'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
CreatePortalType \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddPortalTypeToBusinessTemplate \
FillPortalTypesFields \
FillWrongPortalTypesFields \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
CheckBuildWithBadPortalTypeFailed \
RemovePortalType \
RemoveBusinessTemplate \
RemoveAllTrashBins \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
# test of skins # test of skins
def test_03_BusinessTemplateWithSkins(self, quiet=quiet, run=run_all_test): def test_03_BusinessTemplateWithSkins(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
......
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