Commit 3c9ca89c authored by Vincent Pelletier's avatar Vincent Pelletier

Check that renaming objects preserve their uid.

Check that renaming an object with a subobject updates subobject path.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18537 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3b7f9450
......@@ -1838,6 +1838,49 @@ class TestPropertySheet:
self.assertRaises(ValueError, getattr, not_ok, 'attr')
self.assertFalse(hasattr(not_ok, 'attr'))
def test_renameObjectsPreservesUid(self, quiet=quiet, run=run_all_test):
"""Test that object renaming preserves original uid.
This features allows to avoid reindexing all related objects, as it
can be extremely costly.
"""
if not run: return
folder = self.getOrganisationModule()
initial_id = 'foo'
final_id = 'bar'
folder.newContent(portal_type='Organisation', id=initial_id)
get_transaction().commit()
self.tic()
folder = self.getOrganisationModule()
document = folder[initial_id]
initial_uid = document.uid
folder.manage_renameObjects([initial_id], [final_id])
get_transaction().commit()
self.tic()
folder = self.getOrganisationModule()
document = folder[final_id]
self.assertEqual(initial_uid, document.uid)
def test_renameObjectsReindexSubobjects(self, quiet=quiet, run=run_all_test):
"""Test that renaming an object with subobjects causes them to be
reindexed (their path must be updated).
"""
if not run: return
folder = self.getOrganisationModule()
initial_id = 'foo'
final_id = 'bar'
subdocument_id = 'sub'
object = folder.newContent(portal_type='Organisation', id=initial_id)
object.newContent(id=subdocument_id)
get_transaction().commit()
self.tic()
folder = self.getOrganisationModule()
folder.manage_renameObjects([initial_id], [final_id])
get_transaction().commit()
self.tic()
folder = self.getOrganisationModule()
subdocument = folder[final_id][subdocument_id]
subdocument_catalogged_path = self.getPortalObject().portal_catalog.getSQLCatalog()[subdocument.uid].path
self.assertEqual(subdocument.getPath(), subdocument_catalogged_path)
def test_suite():
suite = unittest.TestSuite()
......
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