Commit e68b8b6b authored by Arnaud Fontaine's avatar Arnaud Fontaine

runUnitTest: Backport d4c2e1c3 from generic ERP5 for 'runUnitTest: ZODB is...

runUnitTest: Backport d4c2e1c3 from generic ERP5 for 'runUnitTest: ZODB is removed on '--save', so also recreate the Catalog tables installed by bt5s.'.

Author: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date:   Thu Feb 4 10:35:33 2016 +0100

    ERP5TypeTestCase: reduce needless ERP5Site_reindexAll call in setUpERP5Site().

    ERP5Site_reindexAll is now called only once when --recreate_catalog=1 is explicitly specified.
    Also manage_catalogClear is not called with --load unless --recreate_catalog=1 is explicitly specified.
parent c086681c
......@@ -916,21 +916,52 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
url_string = '%(hostname)s:%(port)s' % connection_dict
portal_memcached.default_memcached_plugin.setUrlString(url_string)
def _clearActivity(self, quiet=0):
"""Clear activities if `erp5_tests_recreate_catalog` environment variable is
set. """
if int(os.environ.get('erp5_tests_recreate_catalog', 0)):
_start = time.time()
if not quiet:
ZopeTestCase._print('\nRecreating activity tables ... ')
portal = self.getPortal()
portal.portal_activities.manageClearActivities()
self.commit()
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start,))
def _recreateCatalog(self, quiet=0):
"""Clear activities and catalog and recatalog everything.
Test runner can set `erp5_tests_recreate_catalog` environnement variable,
in that case we have to clear catalog. """
if int(os.environ.get('erp5_tests_recreate_catalog', 0)):
_start = time.time()
if not quiet:
ZopeTestCase._print('\nRecreating catalog ... ')
portal = self.getPortal()
portal.portal_catalog.manage_catalogClear()
self.commit()
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start,))
def _updateTranslationTable(self, quiet=0):
_start = time.time()
if not quiet:
ZopeTestCase._print('\nUpdating translation table ... ')
self.portal.ERP5Site_updateTranslationTable()
self.commit()
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start,))
def _reindexSite(self, quiet=0):
"""Reindex site if `erp5_tests_recreate_catalog` environment variable is
set. """
if int(os.environ.get('erp5_tests_recreate_catalog', 0)):
try:
_start = time.time()
if not quiet:
ZopeTestCase._print('\nRecreating catalog ... ')
ZopeTestCase._print('\nReindexing site ... ')
portal = self.getPortal()
portal.portal_activities.manageClearActivities()
portal.portal_catalog.manage_catalogClear()
self.commit()
portal.ERP5Site_reindexAll()
self.tic()
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start,))
finally:
......@@ -974,8 +1005,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
for listbox_line in listbox_object_list:
install_kw[listbox_line.object_id] = listbox_line.choice_item_list[0][1]
bt.install(light_install=light_install,
object_to_update=install_kw,
update_translation=1)
object_to_update=install_kw)
# Release locks
self.commit()
if not quiet:
......@@ -1066,10 +1096,12 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
self.loadPromise()
self._updateConnectionStrings()
self._recreateCatalog()
self._clearActivity()
self._installBusinessTemplateList(business_template_list,
light_install=light_install,
quiet=quiet)
self._recreateCatalog()
self._updateTranslationTable()
self._updateConversionServerConfiguration()
self._updateMemcachedConfiguration()
# Create a Manager user at the Portal level
......@@ -1089,6 +1121,8 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - start))
self._reindexSite()
# Enable reindexing
# Do hot reindexing # Does not work
if hot_reindexing:
......
File mode changed from 100644 to 100755
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