summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_message_compose.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-05-08 14:19:51 +0000
committerThibault Delavallée <tde@odoo.com>2019-09-06 13:27:59 +0000
commit46241ce8a92390a797f6b90d6fbd79014439eec0 (patch)
treea724e26b05377152b0e49f8e8ccf089dd6b7ee73 /addons/test_mail/tests/test_message_compose.py
parenta5ef86754193af40b874f1d097ab50e096368f21 (diff)
[REF] test_mail: lessen data created by default
PURPOSE In order to rewrite some tests, remove low-level tests and add coverage first step is to reorganize a bit test_mail content. Several tests cases are spread among several files and finding back some feature coverage tests is not easy. SPECIFICATIONS Quickly clean common class and lessen data creation by default. Offer some tool methods, notably to create portal users used in some tests but not all, or to create mail templates. LINKS Task 1958697
Diffstat (limited to 'addons/test_mail/tests/test_message_compose.py')
-rw-r--r--addons/test_mail/tests/test_message_compose.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/addons/test_mail/tests/test_message_compose.py b/addons/test_mail/tests/test_message_compose.py
index adf1dd80ae6..d57d356262e 100644
--- a/addons/test_mail/tests/test_message_compose.py
+++ b/addons/test_mail/tests/test_message_compose.py
@@ -16,17 +16,19 @@ from odoo.tools import mute_logger
class TestMessagePost(BaseFunctionalTest, MockEmails, TestRecipients):
- def setUp(self):
- super(TestMessagePost, self).setUp()
+ @classmethod
+ def setUpClass(cls):
+ super(TestMessagePost, cls).setUpClass()
+ cls.test_record = cls.env['mail.test.simple'].with_context(cls._test_context).create({'name': 'Test', 'email_from': 'ignasse@example.com'})
# configure mailing
- self.alias_domain = 'schlouby.fr'
- self.alias_catchall = 'test+catchall'
- self.env['ir.config_parameter'].set_param('mail.catchall.domain', self.alias_domain)
- self.env['ir.config_parameter'].set_param('mail.catchall.alias', self.alias_catchall)
+ cls.alias_domain = 'schlouby.fr'
+ cls.alias_catchall = 'test+catchall'
+ cls.env['ir.config_parameter'].set_param('mail.catchall.domain', cls.alias_domain)
+ cls.env['ir.config_parameter'].set_param('mail.catchall.alias', cls.alias_catchall)
# admin should not receive emails
- self.user_admin.write({'notification_type': 'email'})
+ cls.user_admin.write({'notification_type': 'email'})
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_post_notifications(self):
@@ -223,17 +225,19 @@ class TestMessagePost(BaseFunctionalTest, MockEmails, TestRecipients):
class TestComposer(BaseFunctionalTest, MockEmails, TestRecipients):
- def setUp(self):
- super(TestComposer, self).setUp()
+ @classmethod
+ def setUpClass(cls):
+ super(TestComposer, cls).setUpClass()
+ cls.test_record = cls.env['mail.test.simple'].with_context(cls._test_context).create({'name': 'Test', 'email_from': 'ignasse@example.com'})
# configure mailing
- self.alias_domain = 'schlouby.fr'
- self.alias_catchall = 'test+catchall'
- self.env['ir.config_parameter'].set_param('mail.catchall.domain', self.alias_domain)
- self.env['ir.config_parameter'].set_param('mail.catchall.alias', self.alias_catchall)
+ cls.alias_domain = 'schlouby.fr'
+ cls.alias_catchall = 'test+catchall'
+ cls.env['ir.config_parameter'].set_param('mail.catchall.domain', cls.alias_domain)
+ cls.env['ir.config_parameter'].set_param('mail.catchall.alias', cls.alias_catchall)
# admin should not receive emails
- self.user_admin.write({'notification_type': 'email'})
+ cls.user_admin.write({'notification_type': 'email'})
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_composer_comment(self):
@@ -271,7 +275,7 @@ class TestComposer(BaseFunctionalTest, MockEmails, TestRecipients):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_composer_mass_mail(self):
- test_record_2 = self.env['mail.test.simple'].with_context(BaseFunctionalTest._test_context).create({'name': 'Test2'})
+ test_record_2 = self.env['mail.test.simple'].with_context(self._test_context).create({'name': 'Test2'})
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'mass_mail',
@@ -306,7 +310,7 @@ class TestComposer(BaseFunctionalTest, MockEmails, TestRecipients):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_composer_mass_mail_active_domain(self):
- test_record_2 = self.env['mail.test.simple'].with_context(BaseFunctionalTest._test_context).create({'name': 'Test2'})
+ test_record_2 = self.env['mail.test.simple'].with_context(self._test_context).create({'name': 'Test2'})
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'mass_mail',
@@ -324,7 +328,7 @@ class TestComposer(BaseFunctionalTest, MockEmails, TestRecipients):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_message_compose_mass_mail_no_active_domain(self):
- test_record_2 = self.env['mail.test.simple'].with_context(BaseFunctionalTest._test_context).create({'name': 'Test2'})
+ test_record_2 = self.env['mail.test.simple'].with_context(self._test_context).create({'name': 'Test2'})
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'mass_mail',