Commit 7939c0d8 authored by Aurel's avatar Aurel

raise a more user friendly message, remove trailling spaces

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12671 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 88b120e7
......@@ -610,14 +610,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
portal_type = (portal_type,)
if spec is ():
spec = portal_type
#LOG("set Category",0,str(category_list))
default_dict = {}
self._cleanupCategories(context)
if isinstance(category_list, str):
category_list = (category_list,)
elif category_list is None:
category_list = ()
elif not isinstance(category_list, list):
raise TypeError, 'Category must be a string.'
if isinstance(base_category_list, str):
base_category_list = [base_category_list]
new_category_list = []
......
......@@ -772,6 +772,33 @@ class TestCMFCategory(ERP5TypeTestCase):
packing_list.setCausalityValue(order)
self.assertEquals(packing_list.getDestinationAdministrationPersonTitle(), 'toto')
def test_22_UserFriendlyException(self, quiet=quiet, run=run_all_test):
"""Test message raise if bad use of setter."""
if not run : return
if not quiet:
message = 'Test User Friendly Exception'
ZopeTestCase._print('\n '+message)
LOG('Testing... ',0,message)
person_module = self.getPersonModule()
portal = self.getPortal()
person_module = self.getPersonModule()
if self.id1 not in person_module.objectIds():
p1 = person_module.newContent(id=self.id1, title=self.id1)
else:
p1 = person_module._getOb(self.id1)
organisation_module = self.getOrganisationModule()
organisation_module = self.getOrganisationModule()
if self.id1 not in organisation_module.objectIds():
o1 = organisation_module.newContent(id=self.id1)
else:
o1 = organisation_module._getOb(self.id1)
try:
p1.setCareerSubordination(o1)
except Exception, e:
self.failUnless(isinstance(e, TypeError))
self.assertEqual(e.args[0], 'Category must be a string.')
if __name__ == '__main__':
framework()
else:
......
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