summaryrefslogtreecommitdiff
path: root/addons/test_mail
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-04-29 11:38:20 +0000
committerThibault Delavallée <tde@odoo.com>2020-05-26 10:35:58 +0000
commit4a2ac044f8bd4a5a1f96f0e45c008473dc15eec3 (patch)
tree26d9b7406dadcbe299941f371803f363e6426946 /addons/test_mail
parenta874dfa08abd5b3c54e29c0257dfa23118b910da (diff)
[IMP] (test_)(mass_)mail(_full): rename and reorganize mail related test classes
Modules holding tests and helpers * link_tracker: mainly mock, asserts and tools for link tracker tests (MockLinkTracker); * mail: mainly gateway mock and base for mail tests * MockEmail -> mocks for mail gateway; * MailCase -> tools and asserts for mail tests; * MailCommon -> base for mail functional tests); * sms: mainly SMS gateway mock and base for sms tests * MockSMS -> mocks for SMS gateway; * SMS Case -> tools and asserts for mail / SMS tests; * SMSCommon -> update of MailCommon with SMS capabilities); * mass_mailing: mainly asserts and tools for mass mailing tests * MassMailCase -> update of MailCase for mass mailing tools and asserts; * MassMailCommon -> update of MailCommon with mass mailing); * mass_mailing_sms: mainly asserts and tools for mass SMS tests * MockMassSMS -> update of MockSMS for mass SMS tools and asserts; * MassSMSCommon -> update of MassMailCommon with SMS capabilities); Modules for tests * test_mail: module for mail app tests (TestMailCommon); * test_mass_mailing: module for mass mailing app tests (TestMassMailCommon); * test_mail_full: tests integrating all discuss features, currently mainly mail and SMS (TestMailFullCommon); Enterprise: update test_mail_enterprise and test_marketing_automation Task ID 2247037 Community PR odoo/odoo#50384 Enterprise PR odoo/enterprise#10266 Upgrade PR odoo/upgrade#1122
Diffstat (limited to 'addons/test_mail')
-rw-r--r--addons/test_mail/tests/common.py56
-rw-r--r--addons/test_mail/tests/test_message_composer.py57
2 files changed, 45 insertions, 68 deletions
diff --git a/addons/test_mail/tests/common.py b/addons/test_mail/tests/common.py
index a1b7c7000ea..b62b1a444aa 100644
--- a/addons/test_mail/tests/common.py
+++ b/addons/test_mail/tests/common.py
@@ -1,63 +1,19 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo.addons.mail.tests import common as mail_common
-from odoo.tests import common
+from odoo.addons.mail.tests.common import MailCommon
+from odoo.tests.common import SavepointCase
-mail_new_test_user = mail_common.mail_new_test_user
-
-class TestMailCommon(common.SavepointCase, mail_common.MailCase):
-
- @classmethod
- def setUpClass(cls):
- super(TestMailCommon, cls).setUpClass()
- # give default values for all email aliases and domain
- cls._init_mail_gateway()
- # ensure admin configuration
- cls.user_admin = cls.env.ref('base.user_admin')
- cls.user_admin.write({'notification_type': 'inbox'})
- cls.partner_admin = cls.env.ref('base.partner_admin')
- cls.company_admin = cls.user_admin.company_id
- cls.company_admin.write({'email': 'company@example.com'})
- # test standard employee
- cls.user_employee = mail_new_test_user(
- cls.env, login='employee', groups='base.group_user', company_id=cls.company_admin.id,
- name='Ernest Employee', notification_type='inbox', signature='--\nErnest')
- cls.partner_employee = cls.user_employee.partner_id
+class TestMailCommon(MailCommon):
+ """ Main entry point for functional tests. """
@classmethod
def _create_channel_listener(cls):
cls.channel_listen = cls.env['mail.channel'].with_context(cls._test_context).create({'name': 'Listener'})
- @classmethod
- def _create_portal_user(cls):
- cls.user_portal = mail_new_test_user(
- cls.env, login='portal_test', groups='base.group_portal', company_id=cls.company_admin.id,
- name='Chell Gladys', notification_type='email')
- cls.partner_portal = cls.user_portal.partner_id
- return cls.user_portal
-
- @classmethod
- def _create_template(cls, model, template_values=None):
- create_values = {
- 'name': 'TestTemplate',
- 'subject': 'About ${object.name}',
- 'body_html': '<p>Hello ${object.name}</p>',
- 'model_id': cls.env['ir.model']._get(model).id,
- }
- if template_values:
- create_values.update(template_values)
- cls.email_template = cls.env['mail.template'].create(create_values)
- return cls.email_template
-
- def flush_tracking(self):
- """ Force the creation of tracking values. """
- self.env['base'].flush()
- self.cr.precommit()
-
-class TestMailMultiCompanyCommon(TestMailCommon):
+class TestMailMultiCompanyCommon(MailCommon):
@classmethod
def setUpClass(cls):
@@ -67,7 +23,7 @@ class TestMailMultiCompanyCommon(TestMailCommon):
})
-class TestRecipients(common.SavepointCase):
+class TestRecipients(SavepointCase):
@classmethod
def setUpClass(cls):
diff --git a/addons/test_mail/tests/test_message_composer.py b/addons/test_mail/tests/test_message_composer.py
index e94b5a533c3..a93432a1575 100644
--- a/addons/test_mail/tests/test_message_composer.py
+++ b/addons/test_mail/tests/test_message_composer.py
@@ -207,14 +207,21 @@ class TestComposerWTpl(TestMailCommon, TestRecipients):
composer.send_mail()
new_partners = self.env['res.partner'].search([('email', 'in', [self.email_1, self.email_2])])
- self.assertMailSent(
- self.user_employee.partner_id,
+ self.assertMailMail(
[self.partner_1, self.partner_2, new_partners[0], new_partners[1], self.partner_admin],
- False,
+ 'sent',
+ author=self.user_employee.partner_id,
+ mail_message=False,
check_mail_mail=False,
- subject='About %s' % self.test_record.name,
- body_content=self.test_record.name,
- attachments=[('first.txt', b'My first attachment', 'text/plain'), ('second.txt', b'My second attachment', 'text/plain')])
+ email_values={
+ 'subject': 'About %s' % self.test_record.name,
+ 'body_content': self.test_record.name,
+ 'attachments': [
+ ('first.txt', b'My first attachment', 'text/plain'),
+ ('second.txt', b'My second attachment', 'text/plain')
+ ]
+ }
+ )
def test_composer_template_onchange_attachments(self):
"""Tests that all attachments are added to the composer,
@@ -278,24 +285,38 @@ class TestComposerWTpl(TestMailCommon, TestRecipients):
self._mails_record2 = [dict(mail) for mail in self._mails if '%s-%s' % (test_record_2.id, test_record_2._name) in mail['message_id']]
self._mails = self._mails_record1
- self.assertMailSent(
- self.user_employee.partner_id,
+ self.assertMailMail(
[self.partner_1, self.partner_2, new_partners[0], new_partners[1], self.partner_admin],
- False,
+ 'sent',
+ author=self.user_employee.partner_id,
+ mail_message=False,
check_mail_mail=False,
- subject='About %s' % self.test_record.name,
- body_content=self.test_record.name,
- attachments=[('first.txt', b'My first attachment', 'text/plain'), ('second.txt', b'My second attachment', 'text/plain')])
+ email_values={
+ 'subject': 'About %s' % self.test_record.name,
+ 'body_content': self.test_record.name,
+ 'attachments': [
+ ('first.txt', b'My first attachment', 'text/plain'),
+ ('second.txt', b'My second attachment', 'text/plain')
+ ]
+ }
+ )
self._mails = self._mails_record2
- self.assertMailSent(
- self.user_employee.partner_id,
+ self.assertMailMail(
[self.partner_1, self.partner_2, new_partners[0], new_partners[1], self.partner_admin],
- False,
+ 'sent',
+ author=self.user_employee.partner_id,
+ mail_message=False,
check_mail_mail=False,
- subject='About %s' % test_record_2.name,
- body_content=test_record_2.name,
- attachments=[('first.txt', b'My first attachment', 'text/plain'), ('second.txt', b'My second attachment', 'text/plain')])
+ email_values={
+ 'subject': 'About %s' % test_record_2.name,
+ 'body_content': test_record_2.name,
+ 'attachments': [
+ ('first.txt', b'My first attachment', 'text/plain'),
+ ('second.txt', b'My second attachment', 'text/plain')
+ ]
+ }
+ )
message_1 = self.test_record.message_ids[0]
message_2 = test_record_2.message_ids[0]