[Erp5-report] r14212 - /erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Apr 25 03:02:55 CEST 2007


Author: yo
Date: Wed Apr 25 03:02:54 2007
New Revision: 14212

URL: http://svn.erp5.org?rev=14212&view=rev
Log:
Test if a new uid is long instead of int, and if portal_catalog automatically can fix an int uid.

Modified:
    erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py

Modified: erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py?rev=14212&r1=14211&r2=14212&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py (original)
+++ erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py Wed Apr 25 03:02:54 2007
@@ -518,6 +518,7 @@
     uid_dict = {}
     for i in xrange(UID_BUFFER_SIZE * 3):
       uid = portal_catalog.newUid()
+      self.failUnless(isinstance(uid, long))
       self.failIf(uid in uid_dict)
       uid_dict[uid] = None
   
@@ -1754,6 +1755,37 @@
         [x.path for x in self.getCatalogTool()(
                 portal_type='Organisation',**catalog_kw)])
 
+  def test_54_FixIntUid(self, quiet=quiet, run=run_all_test):
+    if not run: return
+    if not quiet:
+      message = 'Test if portal_catalog ensures that uid is long'
+      ZopeTestCase._print('\n%s ' % message)
+      LOG('Testing... ',0,message)
+    portal_catalog = self.getCatalogTool()
+    portal = self.getPortal()
+
+    module = portal.getDefaultModule('Organisation')
+    organisation = module.newContent(portal_type='Organisation',)
+    # Ensure that the new uid is long.
+    uid = organisation.uid
+    self.failUnless(isinstance(uid, long))
+    get_transaction().commit()
+    self.tic()
+
+    # Ensure that the uid did not change after the indexing.
+    self.assertEquals(organisation.uid, uid)
+
+    # Force to convert the uid to int.
+    self.uid = int(uid)
+    get_transaction().commit()
+    self.tic()
+
+    # After the indexing, the uid must be converted to long automatically,
+    # and the value must be equivalent.
+    self.failUnless(isinstance(uid, long))
+    self.assertEquals(organisation.uid, uid)
+
+
 if __name__ == '__main__':
     framework()
 else:




More information about the Erp5-report mailing list