Commit 660662f4 authored by Jérome Perrin's avatar Jérome Perrin

Folder: do not silently ignore non existant id generator

parent 905e20d9
...@@ -256,7 +256,6 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -256,7 +256,6 @@ class FolderMixIn(ExtensionClass.Base):
Permission is view because we may want to add content to a folder Permission is view because we may want to add content to a folder
without changing the folder content itself. without changing the folder content itself.
XXX
""" """
my_id = None my_id = None
if id_group is None: if id_group is None:
...@@ -273,7 +272,7 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -273,7 +272,7 @@ class FolderMixIn(ExtensionClass.Base):
# default value of id_generator and force safe fallback in this case. # default value of id_generator and force safe fallback in this case.
idGenerator = getattr(self, id_generator, None) idGenerator = getattr(self, id_generator, None)
if idGenerator is None: if idGenerator is None:
idGenerator = self._generateNextId raise ValueError("Could not find id_generator %r" % (id_generator,))
else: else:
idGenerator = self._generateNextId idGenerator = self._generateNextId
my_id = idGenerator() my_id = idGenerator()
......
...@@ -112,6 +112,11 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor): ...@@ -112,6 +112,11 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
obj = self.newContent() obj = self.newContent()
self.assertEquals(obj.getId(), id_generator_id_list[expected_length]) self.assertEquals(obj.getId(), id_generator_id_list[expected_length])
def test_03_unkownGenerateNewId(self):
self.folder.setIdGenerator('no such method')
self.assertRaises(ValueError, self.folder.generateNewId)
self.assertRaises(ValueError, self.folder.newContent)
def _setAllowedContentTypesForFolderType(self, allowed_content_type_list): def _setAllowedContentTypesForFolderType(self, allowed_content_type_list):
"""Set allowed content types for Folder portal type.""" """Set allowed content types for Folder portal type."""
self.getTypesTool().Folder.edit( self.getTypesTool().Folder.edit(
......
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