Commit d0f96d0f authored by Jérome Perrin's avatar Jérome Perrin

Monkey patch Globlals.get_request (previous patch had a typo)

Install iHotFix products
Silent depreciation warning messages
Display the time to install a business template



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7045 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7b3fe8f1
...@@ -15,7 +15,7 @@ def get_request(): ...@@ -15,7 +15,7 @@ def get_request():
return current_app.REQUEST return current_app.REQUEST
Products.ERP5Type.Utils.get_request = get_request Products.ERP5Type.Utils.get_request = get_request
Globals = get_request Globals.get_request = get_request
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Testing.ZopeTestCase.PortalTestCase import PortalTestCase, user_name from Testing.ZopeTestCase.PortalTestCase import PortalTestCase, user_name
...@@ -30,6 +30,10 @@ try: ...@@ -30,6 +30,10 @@ try:
except ImportError: except ImportError:
pass pass
# XXX: Suppress DeprecationWarnings
import warnings
warnings.simplefilter('ignore', DeprecationWarning, append=1)
# Std Zope Products # Std Zope Products
ZopeTestCase.installProduct('ExtFile') ZopeTestCase.installProduct('ExtFile')
ZopeTestCase.installProduct('Photo') ZopeTestCase.installProduct('Photo')
...@@ -44,6 +48,7 @@ ZopeTestCase.installProduct('MailHost') ...@@ -44,6 +48,7 @@ ZopeTestCase.installProduct('MailHost')
ZopeTestCase.installProduct('PageTemplates') ZopeTestCase.installProduct('PageTemplates')
ZopeTestCase.installProduct('PythonScripts') ZopeTestCase.installProduct('PythonScripts')
ZopeTestCase.installProduct('ExternalMethod') ZopeTestCase.installProduct('ExternalMethod')
ZopeTestCase.installProduct('iHotfix')
ZopeTestCase.installProduct('Localizer') ZopeTestCase.installProduct('Localizer')
ZopeTestCase.installProduct('TimerService') ZopeTestCase.installProduct('TimerService')
...@@ -206,7 +211,7 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -206,7 +211,7 @@ class ERP5TypeTestCase(PortalTestCase):
template = '%s.bt5' % id template = '%s.bt5' % id
else: else:
template = template_list[0] template = template_list[0]
else : else:
template = '%s' % template template = '%s' % template
if not os.path.exists(template): if not os.path.exists(template):
template = '%s.bt5' % template template = '%s.bt5' % template
...@@ -300,7 +305,10 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -300,7 +305,10 @@ class ERP5TypeTestCase(PortalTestCase):
# This prevents an infinite loop. # This prevents an infinite loop.
count -= 1 count -= 1
if count == 0: if count == 0:
raise RuntimeError, 'tic is looping forever. These messages are pending: %r' % ([('/'.join(m.object_path), m.method_id, m.processing_node, m.priority) for m in portal_activities.getMessageList()],) raise RuntimeError,\
'tic is looping forever. These messages are pending: %r' % (
[('/'.join(m.object_path), m.method_id, m.processing_node, m.priority)
for m in portal_activities.getMessageList()],)
# This give some time between messages # This give some time between messages
if count % 10 == 0: if count % 10 == 0:
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
...@@ -315,7 +323,6 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -315,7 +323,6 @@ class ERP5TypeTestCase(PortalTestCase):
self.failUnless(i in a, msg) self.failUnless(i in a, msg)
self.assertEquals(len(a), len(b), msg) self.assertEquals(len(a), len(b), msg)
def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name, title='',quiet=0, def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name, title='',quiet=0,
light_install=1,create_activities=1,hot_reindexing=1): light_install=1,create_activities=1,hot_reindexing=1):
''' '''
...@@ -337,16 +344,17 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name, ...@@ -337,16 +344,17 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name,
user = uf.getUserById('ERP5TypeTestCase').__of__(uf) user = uf.getUserById('ERP5TypeTestCase').__of__(uf)
newSecurityManager(None, user) newSecurityManager(None, user)
# Add ERP5 Site # Add ERP5 Site
#factory = app.manage_addProduct['CMFDefault']
#factory.manage_addCMFSite(id)
reindex = 1 reindex = 1
if hot_reindexing: if hot_reindexing:
setattr(app,'isIndexable',0) setattr(app,'isIndexable',0)
reindex = 0 reindex = 0
if not quiet: ZopeTestCase._print('Adding %s ERP5 Site ... \n' % portal_name) if not quiet:
ZopeTestCase._print('Adding %s ERP5 Site ... ' % portal_name)
factory = app.manage_addProduct['ERP5'] # Not needed by ERP5Type factory = app.manage_addProduct['ERP5'] # Not needed by ERP5Type
factory.manage_addERP5Site(portal_name,light_install=light_install, factory.manage_addERP5Site(portal_name,light_install=light_install,
reindex=reindex,create_activities=create_activities) reindex=reindex,create_activities=create_activities)
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start))
# Release locks # Release locks
get_transaction().commit() get_transaction().commit()
portal=app[portal_name] portal=app[portal_name]
...@@ -359,23 +367,22 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name, ...@@ -359,23 +367,22 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name,
removeLocalConstraint(id) removeLocalConstraint(id)
# Disable reindexing before adding templates # Disable reindexing before adding templates
# VERY IMPORTANT: Add some business templates # VERY IMPORTANT: Add some business templates
for url,id in business_template_list: for url, id in business_template_list:
ZopeTestCase._print('Adding %s business template ... \n' % id) start = time.time()
#portal.portal_templates.download('%s.zexp' % id, id=id) ZopeTestCase._print('Adding %s business template ... ' % id)
portal.portal_templates.download(url, id=id) portal.portal_templates.download(url, id=id)
portal.portal_templates[id].install(light_install=light_install) portal.portal_templates[id].install(light_install=light_install)
#from ZODB.utils import oid_repr, readable_tid_repr
#print 'portal._p_oid = %r, portal._p_serial = %r' % (oid_repr(portal._p_oid), readable_tid_repr(portal._p_serial))
# Release locks # Release locks
get_transaction().commit() get_transaction().commit()
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - start))
# Enbable reindexing # Enbable reindexing
# Do hot reindexing # Does not work # Do hot reindexing # Does not work
if hot_reindexing: if hot_reindexing:
setattr(app,'isIndexable',1) setattr(app,'isIndexable', 1)
portal.portal_catalog.manage_hotReindexAll() portal.portal_catalog.manage_hotReindexAll()
get_transaction().commit() get_transaction().commit()
portal_activities = getattr(portal,'portal_activities',None) portal_activities = getattr(portal, 'portal_activities', None)
if portal_activities is not None: if portal_activities is not None:
count = 1000 count = 1000
while len(portal_activities.getMessageList()) > 0: while len(portal_activities.getMessageList()) > 0:
...@@ -384,7 +391,11 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name, ...@@ -384,7 +391,11 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name,
get_transaction().commit() get_transaction().commit()
count -= 1 count -= 1
if count == 0: if count == 0:
raise RuntimeError, 'tic is looping forever. These messages are pending: %r' % ([('/'.join(m.object_path), m.method_id, m.processing_node, m.priority) for m in portal_activities.getMessageList()],) raise RuntimeError, \
'tic is looping forever. These messages are pending: %r' % (
[('/'.join(m.object_path), m.method_id,
m.processing_node, m.priority)
for m in portal_activities.getMessageList()],)
# Reset aq dynamic, so all unit tests will start again # Reset aq dynamic, so all unit tests will start again
from Products.ERP5Type.Base import _aq_reset from Products.ERP5Type.Base import _aq_reset
_aq_reset() _aq_reset()
......
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