summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_mail_mail.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2017-11-21 13:34:51 +0100
committerThibault Delavallée <tde@odoo.com>2017-11-29 10:11:15 +0100
commitd040bfde89fca1c702e6e95c3b808e0b48c2267a (patch)
tree78f4d11e9d1194c878f89be61a4a4b8140b7e5da /addons/test_mail/tests/test_mail_mail.py
parent7a136d6acc3467504e7d6deed7482395e4d55bd8 (diff)
[MOV] (test_)mail: move tests into their dedicated module
Purpose: avoid having useless tables for test models in a production environment.
Diffstat (limited to 'addons/test_mail/tests/test_mail_mail.py')
-rw-r--r--addons/test_mail/tests/test_mail_mail.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/addons/test_mail/tests/test_mail_mail.py b/addons/test_mail/tests/test_mail_mail.py
new file mode 100644
index 00000000000..eeeb22a296f
--- /dev/null
+++ b/addons/test_mail/tests/test_mail_mail.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import itertools
+
+from odoo.addons.test_mail.tests import common as mail_common
+from odoo.tests import common
+from odoo.tools import mute_logger
+
+
+class TestMail(common.SavepointCase, mail_common.MockEmails):
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestMail, cls).setUpClass()
+
+ cls.user_employee = cls.env['res.users'].with_context({
+ 'no_reset_password': True,
+ 'mail_create_nolog': True,
+ 'mail_create_nosubscribe': True,
+ 'mail_notrack': True,
+ }).create({
+ 'name': 'Ernest Employee',
+ 'login': 'ernest',
+ 'email': 'e.e@example.com',
+ 'signature': '--\nErnest',
+ 'notification_type': 'email',
+ 'groups_id': [(6, 0, [cls.env.ref('base.group_user').id])]
+ })
+
+ @mute_logger('odoo.addons.mail.models.mail_mail')
+ def test_mail_message_notify_from_mail_mail(self):
+ # Due ot post-commit hooks, store send emails in every step
+ self.email_to_list = []
+ mail = self.env['mail.mail'].create({
+ 'body_html': '<p>Test</p>',
+ 'email_to': 'test@example.com',
+ 'partner_ids': [(4, self.user_employee.partner_id.id)]
+ })
+ self.email_to_list.extend(itertools.chain.from_iterable(sent_email['email_to'] for sent_email in self._mails if sent_email.get('email_to')))
+ self.assertNotIn(u'Ernest Employee <e.e@example.com>', self.email_to_list)
+ mail.send()
+ self.email_to_list.extend(itertools.chain.from_iterable(sent_email['email_to'] for sent_email in self._mails if sent_email.get('email_to')))
+ self.assertNotIn(u'Ernest Employee <e.e@example.com>', self.email_to_list)
+ self.assertIn(u'test@example.com', self.email_to_list)