Commit ddc39b3b authored by Vincent Pelletier's avatar Vincent Pelletier

testBusinessTemplate,testTemplateTool: Hook on clear catalog API to detect catalog being cleared

And not the implementation detail of what type of activity may spawn in
the subsequent reindexation.
parent 53269ac3
......@@ -124,6 +124,13 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
except OSError:
continue
self.rmdir_list.append(d)
self._has_cleared_catalog = []
from Products.ERP5Catalog.Document.ERP5Catalog import ERP5Catalog
orig_manage_catalogClear = ERP5Catalog.manage_catalogClear
def manage_catalogClear(*args, **kw):
self._has_cleared_catalog.append(None)
return orig_manage_catalogClear(*args, **kw)
ERP5Catalog.manage_catalogClear = manage_catalogClear
def beforeTearDown(self):
"""Remove objects created in tests."""
......@@ -2760,13 +2767,12 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
and m.kw.get('uid') is not None ]
self.assertEqual(len(message_list), 0)
def stepCheckFolderReindexActivityPresence(self, sequence=None, **kw):
def stepCheckHasClearedCatalog(self, sequence=None, **kw):
"""
Check if we have activity for Folder_reindexAll.
"""
message_list = [ m for m in self.portal.portal_activities.getMessageList()
if m.method_id == 'Folder_reindexAll']
self.assertNotEquals(len(message_list), 0)
self.assertTrue(self._has_cleared_catalog)
del self._has_cleared_catalog[:]
def stepCheckPathNotUnindexAfterBuild(self, sequence=None, **kw):
"""
......@@ -3633,7 +3639,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
InstallWithoutForceBusinessTemplate \
CheckFolderReindexActivityPresence \
CheckHasClearedCatalog \
Tic \
CheckInstalledInstallationState \
CheckBuiltBuildingState \
......@@ -4386,7 +4392,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
CheckCatalogPreinstallReturnCatalogMethod \
Tic \
InstallWithoutForceBusinessTemplate \
CheckFolderReindexActivityPresence \
CheckHasClearedCatalog \
Tic \
CheckInstalledInstallationState \
CheckBuiltBuildingState \
......@@ -5486,7 +5492,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
ImportBusinessTemplate \
UseImportBusinessTemplate \
InstallWithoutForceBusinessTemplate \
CheckFolderReindexActivityPresence \
CheckHasClearedCatalog \
Tic \
\
CheckFormGroups \
......@@ -5502,7 +5508,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
UseImportBusinessTemplate \
Tic \
InstallWithoutForceBusinessTemplate \
CheckFolderReindexActivityPresence \
CheckHasClearedCatalog \
Tic \
\
CheckFormGroups \
......
......@@ -83,16 +83,6 @@ class TestTemplateTool(ERP5TypeTestCase):
bt.install(force=1)
self.tic()
def checkFolderReindexAllActivityPresense(self):
message_list = [m for m in self.portal.portal_activities.getMessageList()
if m.method_id == 'Folder_reindexAll']
self.assertNotEquals(len(message_list), 0)
def checkFolderReindexAllActivityNotPresent(self):
message_list = [m for m in self.portal.portal_activities.getMessageList()
if m.method_id == 'Folder_reindexAll']
self.assertEqual(len(message_list), 0)
def testUpdateBT5FromRepository(self):
""" Test the list of bt5 returned for upgrade """
# edit bt5 revision so that it will be marked as updatable
......@@ -544,6 +534,13 @@ class TestTemplateTool(ERP5TypeTestCase):
def test_installBusinessTemplatesFromRepository_update_catalog(self):
""" Test if update catalog is trigger when needed.
"""
has_cleared_catalog = []
from Products.ERP5Catalog.Document.ERP5Catalog import ERP5Catalog
orig_manage_catalogClear = ERP5Catalog.manage_catalogClear
def manage_catalogClear(*args, **kw):
has_cleared_catalog.append(None)
return orig_manage_catalogClear(*args, **kw)
ERP5Catalog.manage_catalogClear = manage_catalogClear
try:
bt5_name = 'erp5_ingestion_mysql_innodb_catalog'
template_tool = self.portal.portal_templates
......@@ -557,7 +554,7 @@ class TestTemplateTool(ERP5TypeTestCase):
bt = template_tool.getInstalledBusinessTemplate(bt5_name)
self.assertNotEquals(bt.getId(), None)
self.commit()
self.checkFolderReindexAllActivityNotPresent()
self.assertFalse(has_cleared_catalog)
# Before launch activities make sure email table is created even
# catalog is not created.
catalog_tool = self.portal.portal_catalog
......@@ -572,7 +569,8 @@ class TestTemplateTool(ERP5TypeTestCase):
bt = template_tool.getInstalledBusinessTemplate(bt5_name)
self.assertEqual(bt.getTitle(), bt5_name)
self.commit()
self.checkFolderReindexAllActivityPresense()
self.assertTrue(has_cleared_catalog)
del has_cleared_catalog[:]
self.tic()
# Install again should not force catalog to be updated
......@@ -583,9 +581,10 @@ class TestTemplateTool(ERP5TypeTestCase):
self.assertNotEquals(bt, None)
self.assertEqual(bt.getTitle(), bt5_name)
self.commit()
self.checkFolderReindexAllActivityNotPresent()
self.assertFalse(has_cleared_catalog)
self.tic()
finally:
ERP5Catalog.manage_catalogClear = orig_manage_catalogClear
# Make sure no broken catalog it will be left behind and propaguated to
# the next tests.
if len(self.portal.portal_activities.getMessageList())>0:
......
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