[Erp5-report] r18537 - /erp5/trunk/products/ERP5Type/tests/testERP5Type.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Dec 28 13:35:46 CET 2007


Author: vincent
Date: Fri Dec 28 13:35:46 2007
New Revision: 18537

URL: http://svn.erp5.org?rev=18537&view=rev
Log:
Check that renaming objects preserve their uid.
Check that renaming an object with a subobject updates subobject path.

Modified:
    erp5/trunk/products/ERP5Type/tests/testERP5Type.py

Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=18537&r1=18536&r2=18537&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py Fri Dec 28 13:35:46 2007
@@ -1838,6 +1838,49 @@
       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()




More information about the Erp5-report mailing list