Commit 7c7d1f0a authored by Rafael Monnerat's avatar Rafael Monnerat

Added new argument to Replace the MailHost by DummyMailHost. This prevent the instance send emails. 

Also introduced one easy way to replace MailHost by DummyMailHost: ERP5TypeTestCase._setUpDummyMailHost.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33770 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fac8311b
...@@ -491,6 +491,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -491,6 +491,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
cfg.instancehome = os.environ['COPY_OF_INSTANCE_HOME'] cfg.instancehome = os.environ['COPY_OF_INSTANCE_HOME']
App.config.setConfiguration(cfg) App.config.setConfiguration(cfg)
use_dummy_mail_host = os.environ.get('use_dummy_mail_host', 0)
template_list = self.getBusinessTemplateList() template_list = self.getBusinessTemplateList()
erp5_catalog_storage = os.environ.get('erp5_catalog_storage', erp5_catalog_storage = os.environ.get('erp5_catalog_storage',
'erp5_mysql_innodb_catalog') 'erp5_mysql_innodb_catalog')
...@@ -523,7 +524,8 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -523,7 +524,8 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
create_activities=create_activities, create_activities=create_activities,
quiet=install_bt5_quiet, quiet=install_bt5_quiet,
hot_reindexing=hot_reindexing, hot_reindexing=hot_reindexing,
erp5_catalog_storage=erp5_catalog_storage) erp5_catalog_storage=erp5_catalog_storage,
use_dummy_mail_host=use_dummy_mail_host)
PortalTestCase.setUp(self) PortalTestCase.setUp(self)
global current_app global current_app
current_app = self.app current_app = self.app
...@@ -561,6 +563,14 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -561,6 +563,14 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
connection_name = connection_string_name.replace('_string', '') connection_name = connection_string_name.replace('_string', '')
getattr(portal, connection_name).edit('', connection_string) getattr(portal, connection_name).edit('', connection_string)
def _setUpDummyMailHost(self):
"""Replace Original Mail Host by Dummy Mail Host.
"""
from Products.ERP5Type.tests.utils import DummyMailHost
if 'MailHost' in self.portal.objectIds():
self.portal.manage_delObjects(['MailHost'])
self.portal._setObject('MailHost', DummyMailHost('MailHost'))
def _updateConversionServerConfiguration(self): def _updateConversionServerConfiguration(self):
"""Update conversion server (Oood) at default site preferences. """Update conversion server (Oood) at default site preferences.
""" """
...@@ -900,7 +910,8 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -900,7 +910,8 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
light_install=1, light_install=1,
create_activities=1, create_activities=1,
hot_reindexing=1, hot_reindexing=1,
erp5_catalog_storage='erp5_mysql_innodb_catalog'): erp5_catalog_storage='erp5_mysql_innodb_catalog',
use_dummy_mail_host=0):
''' '''
Creates an ERP5 site. Creates an ERP5 site.
business_template_list must be specified correctly business_template_list must be specified correctly
...@@ -994,6 +1005,9 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -994,6 +1005,9 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
'Assignor', 'Author', 'Auditor', 'Associate'], []) 'Assignor', 'Author', 'Auditor', 'Associate'], [])
user = uf.getUserById('ERP5TypeTestCase').__of__(uf) user = uf.getUserById('ERP5TypeTestCase').__of__(uf)
if use_dummy_mail_host:
self._setUpDummyMailHost()
setup_once = getattr(self, 'setUpOnce', None) setup_once = getattr(self, 'setUpOnce', None)
if setup_once is not None and \ if setup_once is not None and \
not getattr(portal, 'set_up_once_called', 0): not getattr(portal, 'set_up_once_called', 0):
......
...@@ -90,6 +90,11 @@ Options: ...@@ -90,6 +90,11 @@ Options:
(Oood), the value will be stored at default preference. (Oood), the value will be stored at default preference.
By default 8008 is used. By default 8008 is used.
--use_dummy_mail_host
Replace the MailHost by DummyMailHost. This prevent
the instance send emails. By default Original MailHost
is used.
""" """
def getUnitTestFile(): def getUnitTestFile():
...@@ -510,6 +515,7 @@ def main(): ...@@ -510,6 +515,7 @@ def main():
"enable_full_indexing=", "enable_full_indexing=",
"run_only=", "run_only=",
"update_only=", "update_only=",
"use_dummy_mail_host",
"update_business_templates"] ) "update_business_templates"] )
except getopt.GetoptError, msg: except getopt.GetoptError, msg:
usage(sys.stderr, msg) usage(sys.stderr, msg)
...@@ -574,6 +580,8 @@ def main(): ...@@ -574,6 +580,8 @@ def main():
os.environ["conversion_server_hostname"] = arg os.environ["conversion_server_hostname"] = arg
elif opt == "--conversion_server_port": elif opt == "--conversion_server_port":
os.environ["conversion_server_port"] = arg os.environ["conversion_server_port"] = arg
elif opt == "--use_dummy_mail_host":
os.environ["use_dummy_mail_host"] = "1"
test_list = args test_list = args
if not test_list: if not test_list:
......
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