summaryrefslogtreecommitdiff
path: root/addons/mail/tests
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2021-04-26 12:38:49 +0000
committerThibault Delavallée <tde@odoo.com>2021-04-27 09:15:43 +0000
commitd08942c3ab80a8f573d38c02e8e8a10a1ede5433 (patch)
tree067ab49c28176b19ca639d744440fdb0eda08d02 /addons/mail/tests
parent99f9f6372b3bd18b6dc10b2ff181920dfe90ec80 (diff)
[IMP] test_mass_mailing: add tests for replies to mailings depending on update mode
Purpose of this commit is to add tests related to answers through mail gateway when having reply-to mode of mailing set to either updating existing threads (aka replying on mailed records), either creating new threads (aka using the reply-to alias configuration). Backport of odoo/odoo@4ef24369c813ec6a6ce997369aa454d9d67a992b done in master (14.4) LINKS Task ID-2117639 COM PR odoo/odoo#40931
Diffstat (limited to 'addons/mail/tests')
-rw-r--r--addons/mail/tests/common.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/addons/mail/tests/common.py b/addons/mail/tests/common.py
index 4a688535886..bbd685534d6 100644
--- a/addons/mail/tests/common.py
+++ b/addons/mail/tests/common.py
@@ -128,7 +128,8 @@ class MockEmail(common.BaseCase):
""" Deprecated, remove in 14.4 """
return self.gateway_mail_reply_wrecord(template, record, use_in_reply_to=use_in_reply_to)
- def gateway_mail_reply_wrecord(self, template, record, use_in_reply_to=True):
+ def gateway_mail_reply_wrecord(self, template, record, use_in_reply_to=True,
+ target_model=None, target_field=None):
""" Simulate a reply through the mail gateway. Usage: giving a record,
find an email sent to him and use its message-ID to simulate a reply.
@@ -148,8 +149,32 @@ class MockEmail(common.BaseCase):
subject='Re: %s' % mail_mail.subject,
extra=extra,
msg_id='<123456.%s.%d@test.example.com>' % (record._name, record.id),
- target_model=record._name,
- target_field=record._rec_name,
+ target_model=target_model or record._name,
+ target_field=target_field or record._rec_name,
+ )
+
+ def gateway_mail_reply_wemail(self, template, email_to, use_in_reply_to=True,
+ target_model=None, target_field=None):
+ """ Simulate a reply through the mail gateway. Usage: giving a record,
+ find an email sent to him and use its message-ID to simulate a reply.
+
+ Some noise is added in References just to test some robustness. """
+ sent_mail = self._find_sent_mail_wemail(email_to)
+
+ if use_in_reply_to:
+ extra = 'In-Reply-To:\r\n\t%s\n' % sent_mail['message_id']
+ else:
+ disturbing_other_msg_id = '<123456.654321@another.host.com>'
+ extra = 'References:\r\n\t%s\n\r%s' % (sent_mail['message_id'], disturbing_other_msg_id)
+
+ return self.format_and_process(
+ template,
+ sent_mail['email_to'],
+ sent_mail['reply_to'],
+ subject='Re: %s' % sent_mail['subject'],
+ extra=extra,
+ target_model=target_model,
+ target_field=target_field or 'name',
)
def from_string(self, text):