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