Commit f3bd2ec2 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Test if a new uid is long instead of int, and if portal_catalog automatically can fix an int uid.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14212 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f961abbf
...@@ -518,6 +518,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -518,6 +518,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
uid_dict = {} uid_dict = {}
for i in xrange(UID_BUFFER_SIZE * 3): for i in xrange(UID_BUFFER_SIZE * 3):
uid = portal_catalog.newUid() uid = portal_catalog.newUid()
self.failUnless(isinstance(uid, long))
self.failIf(uid in uid_dict) self.failIf(uid in uid_dict)
uid_dict[uid] = None uid_dict[uid] = None
...@@ -1754,6 +1755,37 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1754,6 +1755,37 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
[x.path for x in self.getCatalogTool()( [x.path for x in self.getCatalogTool()(
portal_type='Organisation',**catalog_kw)]) 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__': if __name__ == '__main__':
framework() framework()
else: else:
......
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