Commit 2d7a90c1 authored by Aurel's avatar Aurel

fake get_context in test to make Localizer work when required


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12890 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3d11c7ad
...@@ -14,6 +14,7 @@ warnings.simplefilter('ignore', DeprecationWarning, append=1) ...@@ -14,6 +14,7 @@ warnings.simplefilter('ignore', DeprecationWarning, append=1)
current_app = None current_app = None
import Products.ERP5Type.Utils import Products.ERP5Type.Utils
import Globals import Globals
# store a copy of the original method # store a copy of the original method
original_get_request = Globals.get_request original_get_request = Globals.get_request
...@@ -23,6 +24,13 @@ def get_request(): ...@@ -23,6 +24,13 @@ def get_request():
Products.ERP5Type.Utils.get_request = get_request Products.ERP5Type.Utils.get_request = get_request
Globals.get_request = get_request Globals.get_request = get_request
import itools.zope
def get_context():
return current_app
itools.zope.get_context = get_context
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Testing.ZopeTestCase.PortalTestCase import PortalTestCase, user_name from Testing.ZopeTestCase.PortalTestCase import PortalTestCase, user_name
from Products.ERP5Type.tests.utils import getMySQLArguments from Products.ERP5Type.tests.utils import getMySQLArguments
...@@ -79,7 +87,7 @@ try: ...@@ -79,7 +87,7 @@ try:
if isinstance(s, UnicodeType): if isinstance(s, UnicodeType):
s = s.encode('utf8', 'repr') s = s.encode('utf8', 'repr')
OrigStringIO.write(self, s) OrigStringIO.write(self, s)
# iHotFix will patch PageTemplate StringIO with # iHotFix will patch PageTemplate StringIO with
iHotfix.iHotfixStringIO = UnicodeSafeStringIO iHotfix.iHotfixStringIO = UnicodeSafeStringIO
except ImportError: except ImportError:
pass pass
...@@ -344,7 +352,7 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -344,7 +352,7 @@ class ERP5TypeTestCase(PortalTestCase):
""" """
ZopeTestCase._print('\n%s ' % message) ZopeTestCase._print('\n%s ' % message)
LOG('Testing ... ', DEBUG, message) LOG('Testing ... ', DEBUG, message)
def _updateConnectionStrings(self): def _updateConnectionStrings(self):
"""Update connection strings with values passed by the testRunner """Update connection strings with values passed by the testRunner
""" """
...@@ -381,10 +389,10 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -381,10 +389,10 @@ class ERP5TypeTestCase(PortalTestCase):
# Utility methods specific to ERP5Type # Utility methods specific to ERP5Type
def getTemplateTool(self): def getTemplateTool(self):
return getToolByName(self.getPortal(), 'portal_templates', None) return getToolByName(self.getPortal(), 'portal_templates', None)
def getPreferenceTool(self) : def getPreferenceTool(self) :
return getToolByName(self.getPortal(), 'portal_preferences', None) return getToolByName(self.getPortal(), 'portal_preferences', None)
def getTrashTool(self): def getTrashTool(self):
return getToolByName(self.getPortal(), 'portal_trash', None) return getToolByName(self.getPortal(), 'portal_trash', None)
...@@ -436,7 +444,7 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -436,7 +444,7 @@ class ERP5TypeTestCase(PortalTestCase):
def getCurrencyModule(self): def getCurrencyModule(self):
return getattr(self.getPortal(), 'currency_module', return getattr(self.getPortal(), 'currency_module',
getattr(self.getPortal(), 'currency', None)) getattr(self.getPortal(), 'currency', None))
def tic(self): def tic(self):
""" """
Start all messages Start all messages
...@@ -510,7 +518,7 @@ def setupERP5Site( business_template_list=(), ...@@ -510,7 +518,7 @@ def setupERP5Site( business_template_list=(),
reindex = 0 reindex = 0
if not quiet: if not quiet:
ZopeTestCase._print('Adding %s ERP5 Site ... ' % portal_name) ZopeTestCase._print('Adding %s ERP5 Site ... ' % portal_name)
extra_constructor_kw = _getConnectionStringDict() extra_constructor_kw = _getConnectionStringDict()
email_from_address = os.environ.get('email_from_address') email_from_address = os.environ.get('email_from_address')
if email_from_address is not None: if email_from_address is not None:
...@@ -586,7 +594,7 @@ def setupERP5Site( business_template_list=(), ...@@ -586,7 +594,7 @@ def setupERP5Site( business_template_list=(),
# 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()
if os.environ.get('erp5_save_data_fs'): if os.environ.get('erp5_save_data_fs'):
# Quit the test in order to get a clean site # Quit the test in order to get a clean site
if not quiet: if not quiet:
......
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