Commit 42f3035a authored by Sebastien Robin's avatar Sebastien Robin

take into the account that unindex use activities now

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11326 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2bd34dc9
...@@ -62,10 +62,12 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -62,10 +62,12 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# Different variables used for this test # Different variables used for this test
run_all_test = 1 run_all_test = 1
quiet = 1 quiet = 0
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self, quiet=1, run=1):
self.login() self.login()
# make sure there is no message any more
self.tic()
def beforeTearDown(self): def beforeTearDown(self):
for module in [ self.getPersonModule(), for module in [ self.getPersonModule(),
...@@ -143,6 +145,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -143,6 +145,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
person.immediateReindexObject() person.immediateReindexObject()
self.checkRelativeUrlInSqlPathList(path_list) self.checkRelativeUrlInSqlPathList(path_list)
person_module.manage_delObjects('1') person_module.manage_delObjects('1')
get_transaction().commit()
self.tic()
self.checkRelativeUrlNotInSqlPathList(path_list) self.checkRelativeUrlNotInSqlPathList(path_list)
# Now we will ask to immediatly reindex # Now we will ask to immediatly reindex
person = person_module.newContent(id='2', person = person_module.newContent(id='2',
...@@ -153,6 +157,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -153,6 +157,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
person.immediateReindexObject() person.immediateReindexObject()
self.checkRelativeUrlInSqlPathList(path_list) self.checkRelativeUrlInSqlPathList(path_list)
person_module.manage_delObjects('2') person_module.manage_delObjects('2')
get_transaction().commit()
self.tic()
self.checkRelativeUrlNotInSqlPathList(path_list) self.checkRelativeUrlNotInSqlPathList(path_list)
# Now we will try with the method deleteContent # Now we will try with the method deleteContent
person = person_module.newContent(id='3',portal_type='Person') person = person_module.newContent(id='3',portal_type='Person')
...@@ -161,6 +167,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -161,6 +167,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
person.immediateReindexObject() person.immediateReindexObject()
self.checkRelativeUrlInSqlPathList(path_list) self.checkRelativeUrlInSqlPathList(path_list)
person_module.deleteContent('3') person_module.deleteContent('3')
# Now delete things is made with activities
self.checkRelativeUrlInSqlPathList(path_list)
get_transaction().commit()
self.tic()
self.checkRelativeUrlNotInSqlPathList(path_list) self.checkRelativeUrlNotInSqlPathList(path_list)
def test_04_SearchFolderWithDeletedObjects(self, quiet=quiet, run=run_all_test): def test_04_SearchFolderWithDeletedObjects(self, quiet=quiet, run=run_all_test):
...@@ -178,6 +188,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -178,6 +188,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(['4'],folder_object_list) self.assertEquals(['4'],folder_object_list)
person.immediateReindexObject() person.immediateReindexObject()
person_module.manage_delObjects('4') person_module.manage_delObjects('4')
get_transaction().commit()
self.tic()
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)
...@@ -200,6 +212,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -200,6 +212,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(['4'],folder_object_list) self.assertEquals(['4'],folder_object_list)
person_module.manage_delObjects('4') person_module.manage_delObjects('4')
get_transaction().commit()
self.tic()
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)
...@@ -223,6 +237,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -223,6 +237,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(['4'],folder_object_list) self.assertEquals(['4'],folder_object_list)
person_module.manage_delObjects('4') person_module.manage_delObjects('4')
get_transaction().commit()
self.tic()
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)
...@@ -811,29 +827,48 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -811,29 +827,48 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
portal = self.getPortal() portal = self.getPortal()
portal.manage_delObjects('erp5_sql_connection') portal.manage_delObjects('erp5_sql_connection')
# Then it must be impossible to delete an object # Then it must be impossible to delete an object
self.assertRaises(AttributeError, person_module.manage_delObjects,'2') uid = person.getUid()
unindex = portal_catalog.unindexObject
self.assertRaises(AttributeError,unindex,person,uid=person.getUid())
get_transaction().abort() get_transaction().abort()
def test_SortOn(self, quiet=quiet, run=run_all_test): def test_SortOn(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet:
message = 'Test Sort On'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
self.assertEquals('catalog.title', self.assertEquals('catalog.title',
self.getCatalogTool().buildSQLQuery( self.getCatalogTool().buildSQLQuery(
sort_on=(('catalog.title', 'ascending'),))['order_by_expression']) sort_on=(('catalog.title', 'ascending'),))['order_by_expression'])
def test_SortOnDescending(self, quiet=quiet, run=run_all_test): def test_SortOnDescending(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet:
message = 'Test Sort On Descending'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
self.assertEquals('catalog.title DESC', self.assertEquals('catalog.title DESC',
self.getCatalogTool().buildSQLQuery( self.getCatalogTool().buildSQLQuery(
sort_on=(('catalog.title', 'descending'),))['order_by_expression']) sort_on=(('catalog.title', 'descending'),))['order_by_expression'])
def test_SortOnUnknownKeys(self, quiet=quiet, run=run_all_test): def test_SortOnUnknownKeys(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not run: return
if not quiet:
message = 'Test Sort On Unknow Keys'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
self.assertEquals('', self.assertEquals('',
self.getCatalogTool().buildSQLQuery( self.getCatalogTool().buildSQLQuery(
sort_on=(('ignored', 'ascending'),))['order_by_expression']) sort_on=(('ignored', 'ascending'),))['order_by_expression'])
def test_SortOnAmbigousKeys(self, quiet=quiet, run=run_all_test): def test_SortOnAmbigousKeys(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet:
message = 'Test Sort On Ambigous Keys'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
# if the sort key is found on the catalog table, it will use that catalog # if the sort key is found on the catalog table, it will use that catalog
# table. # table.
self.assertEquals('catalog.title', self.assertEquals('catalog.title',
...@@ -862,6 +897,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -862,6 +897,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
def test_SortOnMultipleKeys(self, quiet=quiet, run=run_all_test): def test_SortOnMultipleKeys(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet:
message = 'Test Sort On Multiple Keys'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
self.assertEquals('catalog.title,catalog.id', self.assertEquals('catalog.title,catalog.id',
self.getCatalogTool().buildSQLQuery( self.getCatalogTool().buildSQLQuery(
sort_on=(('catalog.title', 'ascending'), sort_on=(('catalog.title', 'ascending'),
...@@ -872,6 +911,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -872,6 +911,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""Sort-on parameter and related key. (Assumes that region_title is a \ """Sort-on parameter and related key. (Assumes that region_title is a \
valid related key)""" valid related key)"""
if not run: return if not run: return
if not quiet:
message = 'Test Sort On Related Keys'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
self.assertNotEquals('', self.assertNotEquals('',
self.getCatalogTool().buildSQLQuery(region_title='', self.getCatalogTool().buildSQLQuery(region_title='',
sort_on=(('region_title', 'ascending'),))['order_by_expression']) sort_on=(('region_title', 'ascending'),))['order_by_expression'])
...@@ -901,6 +944,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -901,6 +944,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter. """use a dict as a keyword parameter.
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Simple Query Dict'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
organisation_title = 'Nexedi Organisation' organisation_title = 'Nexedi Organisation'
organisation = self._makeOrganisation(title=organisation_title) organisation = self._makeOrganisation(title=organisation_title)
self.assertEquals([organisation.getPath()], self.assertEquals([organisation.getPath()],
...@@ -911,6 +958,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -911,6 +958,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, but using a related key """use a dict as a keyword parameter, but using a related key
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Related Key Simple Query Dict'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
organisation = self._makeOrganisation() organisation = self._makeOrganisation()
self.assertEquals([organisation.getPath()], self.assertEquals([organisation.getPath()],
[x.path for x in self.getCatalogTool()( [x.path for x in self.getCatalogTool()(
...@@ -924,6 +975,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -924,6 +975,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, with OR operator. """use a dict as a keyword parameter, with OR operator.
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Query Dict With Or Operator'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
organisation_title = 'Nexedi Organisation' organisation_title = 'Nexedi Organisation'
organisation = self._makeOrganisation(title=organisation_title) organisation = self._makeOrganisation(title=organisation_title)
...@@ -937,6 +992,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -937,6 +992,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, with AND operator. """use a dict as a keyword parameter, with AND operator.
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Query Dict With And Operator'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
organisation_title = 'Nexedi Organisation' organisation_title = 'Nexedi Organisation'
organisation = self._makeOrganisation(title=organisation_title) organisation = self._makeOrganisation(title=organisation_title)
...@@ -951,6 +1010,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -951,6 +1010,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, with max range parameter ( < ) """use a dict as a keyword parameter, with max range parameter ( < )
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Query Dict With Max Range Operator'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
org_a = self._makeOrganisation(title='A') org_a = self._makeOrganisation(title='A')
org_b = self._makeOrganisation(title='B') org_b = self._makeOrganisation(title='B')
org_c = self._makeOrganisation(title='C') org_c = self._makeOrganisation(title='C')
...@@ -965,6 +1028,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -965,6 +1028,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, with min range parameter ( >= ) """use a dict as a keyword parameter, with min range parameter ( >= )
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Query Dict With Min Range Operator'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
org_a = self._makeOrganisation(title='A') org_a = self._makeOrganisation(title='A')
org_b = self._makeOrganisation(title='B') org_b = self._makeOrganisation(title='B')
org_c = self._makeOrganisation(title='C') org_c = self._makeOrganisation(title='C')
...@@ -980,6 +1047,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -980,6 +1047,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, with ngt range parameter ( <= ) """use a dict as a keyword parameter, with ngt range parameter ( <= )
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Query Dict With Ngt Range Operator'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
org_a = self._makeOrganisation(title='A') org_a = self._makeOrganisation(title='A')
org_b = self._makeOrganisation(title='B') org_b = self._makeOrganisation(title='B')
org_c = self._makeOrganisation(title='C') org_c = self._makeOrganisation(title='C')
...@@ -994,6 +1065,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -994,6 +1065,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, with minmax range parameter ( >= < ) """use a dict as a keyword parameter, with minmax range parameter ( >= < )
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Query Dict With Min Max Range Operator'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
org_a = self._makeOrganisation(title='A') org_a = self._makeOrganisation(title='A')
org_b = self._makeOrganisation(title='B') org_b = self._makeOrganisation(title='B')
org_c = self._makeOrganisation(title='C') org_c = self._makeOrganisation(title='C')
...@@ -1008,6 +1083,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1008,6 +1083,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""use a dict as a keyword parameter, with minngt range parameter ( >= <= ) """use a dict as a keyword parameter, with minngt range parameter ( >= <= )
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Query Dict With Min Ngt Range Operator'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
org_a = self._makeOrganisation(title='A') org_a = self._makeOrganisation(title='A')
org_b = self._makeOrganisation(title='B') org_b = self._makeOrganisation(title='B')
org_c = self._makeOrganisation(title='C') org_c = self._makeOrganisation(title='C')
...@@ -1021,6 +1100,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1021,6 +1100,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""ERP5Catalog uses a deferred connection for full text indexing. """ERP5Catalog uses a deferred connection for full text indexing.
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Deferred Connection'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
erp5_sql_deferred_connection = getattr(self.getPortal(), erp5_sql_deferred_connection = getattr(self.getPortal(),
'erp5_sql_deferred_connection', 'erp5_sql_deferred_connection',
None) None)
...@@ -1039,6 +1122,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1039,6 +1122,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""Simple test to exercise object deletion """Simple test to exercise object deletion
""" """
if not run: return if not run: return
if not quiet:
message = 'Test Delete Object'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
folder = self.getOrganisationModule() folder = self.getOrganisationModule()
ob = folder.newContent() ob = folder.newContent()
get_transaction().commit() get_transaction().commit()
...@@ -1052,6 +1139,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1052,6 +1139,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""test that proxy roles apply to catalog queries within python scripts """test that proxy roles apply to catalog queries within python scripts
""" """
if not run: return if not run: return
if not quiet:
message = 'Proxy Roles In Restricted Python'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
login = PortalTestCase.login login = PortalTestCase.login
perm = 'View' perm = 'View'
...@@ -1105,6 +1196,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1105,6 +1196,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
"""Tests SearchableText is working in ERP5Catalog """Tests SearchableText is working in ERP5Catalog
""" """
if not run: return if not run: return
if not quiet:
message = 'Searchable Text'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ',0,message)
folder = self.getOrganisationModule() folder = self.getOrganisationModule()
ob = folder.newContent() ob = folder.newContent()
ob.setTitle('The title of this object') ob.setTitle('The title of this object')
......
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