[FIX] base: prevent PhantomJS tests to send emails
The emails sending is skipped during the tests. The mecanism to determine if the server was running tests was to check if the attribute `testing` was set for the thread. Unfortunately, this `testing` attribute is removed/set to false after the loading/installation of the modules is done, and phantomJS tests are ran post-installation, and therefore the emails that were potentialy sent following an action performed in a PhantomJS tour were not skipped. This occurred for instance in the tour `project.tour`, when the responsible of a task was changed, the sending of the assignation notification email was not skipped. In the case the machine on which the tests are ran does not have an smtp server (or mailcatcher) running on the port 25, this resulted in a test fail.
This commit is contained in:
@@ -409,7 +409,7 @@ class IrMailServer(models.Model):
|
||||
message['To'] = x_forge_to
|
||||
|
||||
# Do not actually send emails in testing mode!
|
||||
if getattr(threading.currentThread(), 'testing', False):
|
||||
if getattr(threading.currentThread(), 'testing', False) or self.env.registry.in_test_mode():
|
||||
_test_logger.info("skip sending email in test mode")
|
||||
return message['Message-Id']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user