Commit 026fa8f9 authored by Romain Courteaud's avatar Romain Courteaud

Check that creating a temp_object do not write data in ZODB.

Currently, when calling newContent with parameter temp_object=1, container last
ID is modified, and it leads to ConflictError (when using Domain for example).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20338 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3af821e9
...@@ -290,6 +290,32 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -290,6 +290,32 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.logout() self.logout()
self.login() self.login()
# Check that temp object creation do not write in the ZODB
class WriteError(Exception):
pass
def _setLastId(self, id):
raise WriteError
portal.person_module.__class__._setLastId = _setLastId
try:
try:
o = portal.person_module.newContent(portal_type="Person",
temp_object=1)
except WriteError:
raise self.failureException, "Container last ID modified"
finally:
delattr(portal.person_module.__class__, '_setLastId')
# Check that creating 2 consecutive temp object automatically increases
# their ID
o = portal.person_module.newContent(portal_type="Person",
temp_object=1)
first_id = o.getId()
o = portal.person_module.newContent(portal_type="Person",
temp_object=1)
second_id = o.getId()
self.assertNotEquals(first_id, second_id)
self.assertEquals(str(int(first_id) + 1), second_id)
def test_04_CategoryAccessors(self, quiet=quiet, run=run_all_test): def test_04_CategoryAccessors(self, quiet=quiet, run=run_all_test):
""" """
This test provides basic testing of category This test provides basic testing of category
......
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