Commit 28fcf85c authored by Jérome Perrin's avatar Jérome Perrin

add a test for _uid dynamic related key

remove obsolete comments
run tests quietly




git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8978 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ca6c880
...@@ -58,6 +58,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -58,6 +58,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
# Different variables used for this test # Different variables used for this test
run_all_test = 1 run_all_test = 1
quiet = 1
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self, quiet=1, run=1):
self.login() self.login()
...@@ -98,8 +99,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -98,8 +99,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
self.failUnless(path not in path_list) self.failUnless(path not in path_list)
LOG('checkRelativeUrlInSqlPathList not found path:',0,path) LOG('checkRelativeUrlInSqlPathList not found path:',0,path)
def test_01_HasEverything(self, quiet=0, run=run_all_test): def test_01_HasEverything(self, quiet=quiet, run=run_all_test):
# Test if portal_synchronizations was created
if not run: return if not run: return
if not quiet: if not quiet:
ZopeTestCase._print('\nTest Has Everything ') ZopeTestCase._print('\nTest Has Everything ')
...@@ -110,8 +110,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -110,8 +110,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
self.failUnless(self.getSqlConnection()!=None) self.failUnless(self.getSqlConnection()!=None)
self.failUnless(self.getCatalogTool()!=None) self.failUnless(self.getCatalogTool()!=None)
def test_02_EverythingCatalogued(self, quiet=0, run=run_all_test): def test_02_EverythingCatalogued(self, quiet=quiet, run=run_all_test):
# Test if portal_synchronizations was created
if not run: return if not run: return
if not quiet: if not quiet:
ZopeTestCase._print('\nTest Everything Catalogued') ZopeTestCase._print('\nTest Everything Catalogued')
...@@ -121,8 +120,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -121,8 +120,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
organisation_module_list = portal_catalog(portal_type='Organisation Module') organisation_module_list = portal_catalog(portal_type='Organisation Module')
self.assertEquals(len(organisation_module_list),1) self.assertEquals(len(organisation_module_list),1)
def test_03_CreateAndDeleteObject(self, quiet=0, run=run_all_test): def test_03_CreateAndDeleteObject(self, quiet=quiet, run=run_all_test):
# Test if portal_synchronizations was created
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Test Create And Delete Objects' message = 'Test Create And Delete Objects'
...@@ -156,8 +154,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -156,8 +154,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
person_module.deleteContent('3') person_module.deleteContent('3')
self.checkRelativeUrlNotInSqlPathList(path_list) self.checkRelativeUrlNotInSqlPathList(path_list)
def test_04_SearchFolderWithDeletedObjects(self, quiet=0, run=run_all_test): def test_04_SearchFolderWithDeletedObjects(self, quiet=quiet, run=run_all_test):
# Test if portal_synchronizations was created
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Search Folder With Deleted Objects' message = 'Search Folder With Deleted Objects'
...@@ -175,8 +172,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -175,8 +172,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()] folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()]
self.assertEquals([],folder_object_list) self.assertEquals([],folder_object_list)
def test_05_SearchFolderWithImmediateReindexObject(self, quiet=0, run=run_all_test): def test_05_SearchFolderWithImmediateReindexObject(self, quiet=quiet, run=run_all_test):
# Test if portal_synchronizations was created
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Search Folder With Immediate Reindex Object' message = 'Search Folder With Immediate Reindex Object'
...@@ -198,8 +194,8 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -198,8 +194,8 @@ class TestERP5Catalog(ERP5TypeTestCase):
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()] folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()]
self.assertEquals([],folder_object_list) self.assertEquals([],folder_object_list)
def test_06_SearchFolderWithRecursiveImmediateReindexObject(self, quiet=0, run=run_all_test): def test_06_SearchFolderWithRecursiveImmediateReindexObject(self,
# Test if portal_synchronizations was created quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Search Folder With Recursive Immediate Reindex Object' message = 'Search Folder With Recursive Immediate Reindex Object'
...@@ -221,7 +217,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -221,7 +217,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()] folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()]
self.assertEquals([],folder_object_list) self.assertEquals([],folder_object_list)
def test_07_ClearCatalogAndTestNewContent(self, quiet=0, run=run_all_test): def test_07_ClearCatalogAndTestNewContent(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Clear Catalog And Test New Content' message = 'Clear Catalog And Test New Content'
...@@ -238,7 +234,8 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -238,7 +234,8 @@ class TestERP5Catalog(ERP5TypeTestCase):
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()] folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()]
self.assertEquals(['4'],folder_object_list) self.assertEquals(['4'],folder_object_list)
def test_08_ClearCatalogAndTestRecursiveImmediateReindexObject(self, quiet=0, run=run_all_test): def test_08_ClearCatalogAndTestRecursiveImmediateReindexObject(self,
quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Clear Catalog And Test Recursive Immediate Reindex Object' message = 'Clear Catalog And Test Recursive Immediate Reindex Object'
...@@ -256,7 +253,8 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -256,7 +253,8 @@ class TestERP5Catalog(ERP5TypeTestCase):
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()] folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()]
self.assertEquals(['4'],folder_object_list) self.assertEquals(['4'],folder_object_list)
def test_09_ClearCatalogAndTestImmediateReindexObject(self, quiet=0, run=run_all_test): def test_09_ClearCatalogAndTestImmediateReindexObject(self, quiet=quiet,
run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Clear Catalog And Test Immediate Reindex Object' message = 'Clear Catalog And Test Immediate Reindex Object'
...@@ -274,7 +272,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -274,7 +272,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()] folder_object_list = [x.getObject().getId() for x in person_module.searchFolder()]
self.assertEquals(['4'],folder_object_list) self.assertEquals(['4'],folder_object_list)
def test_10_OrderedSearchFolder(self, quiet=0, run=run_all_test): def test_10_OrderedSearchFolder(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Ordered Search Folder' message = 'Ordered Search Folder'
...@@ -293,14 +291,19 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -293,14 +291,19 @@ class TestERP5Catalog(ERP5TypeTestCase):
person.immediateReindexObject() person.immediateReindexObject()
person = person_module.newContent(id='c',portal_type='Person',title='a',description='x') person = person_module.newContent(id='c',portal_type='Person',title='a',description='x')
person.immediateReindexObject() person.immediateReindexObject()
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('id','ascending')])] folder_object_list = [x.getObject().getId()
for x in person_module.searchFolder(sort_on=[('id','ascending')])]
self.assertEquals(['a','b','c'],folder_object_list) self.assertEquals(['a','b','c'],folder_object_list)
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('title','ascending'),('description','ascending')])] folder_object_list = [x.getObject().getId()
for x in person_module.searchFolder(
sort_on=[('title','ascending'), ('description','ascending')])]
self.assertEquals(['c','b','a'],folder_object_list) self.assertEquals(['c','b','a'],folder_object_list)
folder_object_list = [x.getObject().getId() for x in person_module.searchFolder(sort_on=[('title','ascending'),('description','descending')])] folder_object_list = [x.getObject().getId()
for x in person_module.searchFolder(
sort_on=[('title','ascending'),('description','descending')])]
self.assertEquals(['a','b','c'],folder_object_list) self.assertEquals(['a','b','c'],folder_object_list)
def test_11_CastStringAsInt(self, quiet=0, run=run_all_test): def test_11_CastStringAsInt(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Cast String As Int With Order By' message = 'Cast String As Int With Order By'
...@@ -324,7 +327,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -324,7 +327,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
folder_object_list = [x.getObject().getTitle() for x in person_module.searchFolder(sort_on=[('title','ascending','int')])] folder_object_list = [x.getObject().getTitle() for x in person_module.searchFolder(sort_on=[('title','ascending','int')])]
self.assertEquals(['1','2','12'],folder_object_list) self.assertEquals(['1','2','12'],folder_object_list)
def test_12_TransactionalUidBuffer(self, quiet=0, run=run_all_test): def test_12_TransactionalUidBuffer(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Transactional Uid Buffer' message = 'Transactional Uid Buffer'
...@@ -350,7 +353,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -350,7 +353,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
get_transaction().abort() get_transaction().abort()
self.failUnless(len(getattr(catalog, '_v_uid_buffer', [])) == 0) self.failUnless(len(getattr(catalog, '_v_uid_buffer', [])) == 0)
def test_13_ERP5Site_reindexAll(self, quiet=0, run=run_all_test): def test_13_ERP5Site_reindexAll(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'ERP5Site_reindexAll' message = 'ERP5Site_reindexAll'
...@@ -395,7 +398,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -395,7 +398,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
organisation.getRelativeUrl(), organisation.getRelativeUrl(),
'portal_categories/%s' % base_category.getRelativeUrl()]) 'portal_categories/%s' % base_category.getRelativeUrl()])
def test_14_ReindexWithBrokenCategory(self, quiet=0, run=run_all_test): def test_14_ReindexWithBrokenCategory(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Reindexing an object with 1 broken category must not'\ message = 'Reindexing an object with 1 broken category must not'\
...@@ -460,18 +463,17 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -460,18 +463,17 @@ class TestERP5Catalog(ERP5TypeTestCase):
self.assertEquals(theorical_count, cataloged_obj_count, self.assertEquals(theorical_count, cataloged_obj_count,
'category %s is not cataloged correctly' % base_cat) 'category %s is not cataloged correctly' % base_cat)
def test_15_getObject(self, quiet=0, run=run_all_test): def test_15_getObject(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'getObject' message = 'getObject'
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
# portal_catalog.getObject should return None if the UID parameters # portal_catalog.getObject raises a ValueError if UID parameter is a string
# is a string
portal_catalog = self.getCatalogTool() portal_catalog = self.getCatalogTool()
self.assertRaises(ValueError, portal_catalog.getObject, "StringUID") self.assertRaises(ValueError, portal_catalog.getObject, "StringUID")
def test_16_newUid(self, quiet=0, run=run_all_test): def test_16_newUid(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'newUid' message = 'newUid'
...@@ -486,7 +488,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -486,7 +488,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
self.failIf(uid in uid_dict) self.failIf(uid in uid_dict)
uid_dict[uid] = None uid_dict[uid] = None
def test_17_CreationDate_ModificationDate(self, quiet=0, run=run_all_test): def test_17_CreationDate_ModificationDate(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'getCreationDate, getModificationDate' message = 'getCreationDate, getModificationDate'
...@@ -526,7 +528,7 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -526,7 +528,7 @@ class TestERP5Catalog(ERP5TypeTestCase):
self.assertTrue(organisation.getModificationDate()>now) self.assertTrue(organisation.getModificationDate()>now)
self.assertTrue(result[0]['creation_date']<result[0]['modification_date']) self.assertTrue(result[0]['creation_date']<result[0]['modification_date'])
def test_18_buildSQLQuery(self, quiet=0, run=0) :#run_all_test): def test_18_buildSQLQuery(self, quiet=quiet, run=0) :#run_all_test):
"""Tests that buildSQLQuery works with another query_table than 'catalog'""" """Tests that buildSQLQuery works with another query_table than 'catalog'"""
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -640,8 +642,8 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -640,8 +642,8 @@ class TestERP5Catalog(ERP5TypeTestCase):
source_organisation.getUid(), source_organisation.getUid(),
testMethod(src__=1, **kw) ) testMethod(src__=1, **kw) )
def test_19_SearchFolderWithNonAsciiCharacter(self, quiet=0, run=run_all_test): def test_19_SearchFolderWithNonAsciiCharacter(self,
# Test if portal_synchronizations was created quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Search Folder With Non Ascii Character' message = 'Search Folder With Non Ascii Character'
...@@ -660,8 +662,9 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -660,8 +662,9 @@ class TestERP5Catalog(ERP5TypeTestCase):
person_module.searchFolder(title=title)] person_module.searchFolder(title=title)]
self.assertEquals(['5'],folder_object_list) self.assertEquals(['5'],folder_object_list)
def test_20_SearchFolderWithDynamicRelatedKey(self, quiet=0, run=run_all_test):
# Test if portal_synchronizations was created def test_20_SearchFolderWithDynamicRelatedKey(self,
quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
message = 'Search Folder With Dynamic Related Key' message = 'Search Folder With Dynamic Related Key'
...@@ -718,5 +721,9 @@ class TestERP5Catalog(ERP5TypeTestCase): ...@@ -718,5 +721,9 @@ class TestERP5Catalog(ERP5TypeTestCase):
organisation_list = [x.getObject() for x in organisation_list = [x.getObject() for x in
module.searchFolder(group_relative_url=group_relative_url)] module.searchFolder(group_relative_url=group_relative_url)]
self.assertEquals(organisation_list, [organisation]) self.assertEquals(organisation_list, [organisation])
# Try to get the organisation with group uid
organisation_list = [x.getObject() for x in
module.searchFolder(group_uid=group_nexedi_category.getUid())]
self.assertEquals(organisation_list, [organisation])
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