summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/common.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-04-15 15:33:23 +0000
committerThibault Delavallée <tde@odoo.com>2019-04-26 10:28:09 +0000
commite87189222dfcb1c2ca3285862c9d7a28d6ea1426 (patch)
treef5943ce9a4458504f4bac0d5595db9324468413e /addons/test_mail/tests/common.py
parent6aac6418fc1d0a37ae4e9165d73485f34638a3ef (diff)
[IMP] test_mail: add tests for mail gateway and perform light cleaning
This commit add some tests related to the mail gateway: more bounce management tests and some additional thread formation tests. Some test asserts about bounce / blacklist management are commented as they are not completely working currently. This will be improved in master soon. Some cleaning in also done in all mail gateway tests. Notably some call to tool methods are cleaned / simplified, duplicate tests are removed. Some low-level checks are removed. A new test model is added for mail gateway: mail.test.gateway. It is a chatter model with blacklist enabled on it. It allows to tests the various blacklist-related overrides and features as well as all basic mail gateway features. Sub-part of task 1853147 (pre-cleaning before implementing mail gateway improvements) Linked to PR #32974
Diffstat (limited to 'addons/test_mail/tests/common.py')
-rw-r--r--addons/test_mail/tests/common.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/addons/test_mail/tests/common.py b/addons/test_mail/tests/common.py
index 531bf4ea225..fd6ec9ce627 100644
--- a/addons/test_mail/tests/common.py
+++ b/addons/test_mail/tests/common.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import json
+import time
from contextlib import contextmanager
from email.utils import formataddr
@@ -254,11 +255,12 @@ class MockEmails(common.SingleTransactionCase):
cc='', msg_id='<1198923581.41972151344608186760.JavaMail@agrolait.com>'):
return template.format(to=to, subject=subject, cc=cc, extra=extra, email_from=email_from, msg_id=msg_id)
- def format_and_process(self, template, to='groups@example.com, other@gmail.com', subject='Frogs',
- extra='', email_from='Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>',
- cc='', msg_id='<1198923581.41972151344608186760.JavaMail@agrolait.com>',
- model=None, target_model='mail.test.simple', target_field='name'):
+ def format_and_process(self, template, email_from, to, subject='Frogs', extra='', cc='', msg_id=False,
+ model=None, target_model='mail.test.gateway', target_field='name'):
self.assertFalse(self.env[target_model].search([(target_field, '=', subject)]))
+ if not msg_id:
+ msg_id = "<%.7f-test@iron.sky>" % (time.time())
+
mail = self.format(template, to=to, subject=subject, cc=cc, extra=extra, email_from=email_from, msg_id=msg_id)
self.env['mail.thread'].with_context(mail_channel_noautofollow=True).message_process(model, mail)
return self.env[target_model].search([(target_field, '=', subject)])