Raphael Collet (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-test-mode-rco into lp:openobject-server.
Requested reviews:
Olivier Dony (OpenERP) (odo-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-test-mode-rco/+merge/84121
Set a flag 'testing' (with value True) on the current thread when tests are
loaded.
Use this flag in ir_mail_server to prevent sending emails during testing.
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-test-mode-rco/+merge/84121
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-test-mode-rco.
=== modified file 'openerp/addons/base/ir/ir_mail_server.py'
--- openerp/addons/base/ir/ir_mail_server.py 2011-10-17 14:57:14 +0000
+++ openerp/addons/base/ir/ir_mail_server.py 2011-12-01 15:40:37 +0000
@@ -381,6 +381,10 @@
smtp_to_list = filter(None, tools.flatten(map(extract_rfc2822_addresses,[email_to, email_cc, email_bcc])))
assert smtp_to_list, "At least one valid recipient address should be specified for outgoing emails (To/Cc/Bcc)"
+ # Do not actually send emails in testing mode!
+ if getattr(threading.currentThread(), 'testing', False):
+ return message['Message-Id']
+
# Get SMTP Server Details from Mail Server
mail_server = None
if mail_server_id:
=== modified file 'openerp/modules/loading.py'
--- openerp/modules/loading.py 2011-10-17 14:46:15 +0000
+++ openerp/modules/loading.py 2011-12-01 15:40:37 +0000
@@ -31,6 +31,7 @@
import os
import re
import sys
+import threading
import zipfile
import zipimport
@@ -97,11 +98,13 @@
cr.commit()
if not tools.config.options['test_disable']:
try:
+ threading.currentThread().testing = True
_load_data(cr, module_name, idref, mode, 'test')
except Exception, e:
logging.getLogger('init.test').exception(
'Tests failed to execute in module %s', module_name)
finally:
+ threading.currentThread().testing = False
if tools.config.options['test_commit']:
cr.commit()
else:
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp