summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-09-06 11:42:50 +0000
committerThibault Delavallée <tde@odoo.com>2019-09-06 13:37:56 +0000
commit6ccaae1b2f3fbbbd686de976e10439c45f7804de (patch)
treee8a6e0f31bd54b552ffed94149c5f8f8782ad85e /addons/test_mail/tests
parent8a8da21d2ecc59542be549812b2c6b89bd86f3db (diff)
[MOV] test_mail: split cc tests to either discuss or mailgateway tests
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 Split cc tests to either discuss or mail gateway tests. It allows to remove an unnecessary file. LINKS Task 1958697
Diffstat (limited to 'addons/test_mail/tests')
-rw-r--r--addons/test_mail/tests/__init__.py3
-rw-r--r--addons/test_mail/tests/test_discuss.py10
-rw-r--r--addons/test_mail/tests/test_mail_cc.py63
-rw-r--r--addons/test_mail/tests/test_mail_gateway.py49
4 files changed, 56 insertions, 69 deletions
diff --git a/addons/test_mail/tests/__init__.py b/addons/test_mail/tests/__init__.py
index 75891bb0e8d..78d3b1516b6 100644
--- a/addons/test_mail/tests/__init__.py
+++ b/addons/test_mail/tests/__init__.py
@@ -7,12 +7,11 @@ from . import test_mail_activity
from . import test_mail_followers
from . import test_mail_message
from . import test_mail_mail
-from . import test_mail_cc
from . import test_mail_channel
from . import test_mail_gateway
from . import test_mail_redirect
from . import test_mail_template
-from . import test_message_composerr
+from . import test_message_composer
from . import test_message_management
from . import test_message_post
from . import test_message_track
diff --git a/addons/test_mail/tests/test_discuss.py b/addons/test_mail/tests/test_discuss.py
index d81f989383e..be255274ea3 100644
--- a/addons/test_mail/tests/test_discuss.py
+++ b/addons/test_mail/tests/test_discuss.py
@@ -120,3 +120,13 @@ class TestDiscuss(BaseFunctionalTest, TestRecipients, MockEmails):
msg.toggle_message_starred()
self.assertFalse(msg.starred)
self.assertTrue(msg_emp.starred)
+
+ @mute_logger('odoo.addons.mail.models.mail_mail')
+ def test_mail_cc_recipient_suggestion(self):
+ record = self.env['mail.test.cc'].create({'email_cc': 'cc1@example.com, cc2@example.com, cc3 <cc3@example.com>'})
+ suggestions = record._message_get_suggested_recipients()[record.id]
+ self.assertEqual(sorted(suggestions), [
+ (False, 'cc1@example.com', 'CC Email'),
+ (False, 'cc2@example.com', 'CC Email'),
+ (False, 'cc3 <cc3@example.com>', 'CC Email')
+ ], 'cc should be in suggestions')
diff --git a/addons/test_mail/tests/test_mail_cc.py b/addons/test_mail/tests/test_mail_cc.py
deleted file mode 100644
index 45503d3b649..00000000000
--- a/addons/test_mail/tests/test_mail_cc.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from odoo.addons.test_mail.tests import common
-from odoo.tests import tagged
-from odoo.tools import mute_logger, email_split_and_format
-from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE
-
-
-@tagged('mail_thread_cc')
-class TestMailCc(common.BaseFunctionalTest, common.MockEmails):
-
- @classmethod
- def setUpClass(cls):
- super(TestMailCc, cls).setUpClass()
-
- cls.email_from = 'Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>'
- cls.alias = cls.env['mail.alias'].create({
- 'alias_name': 'cc_record',
- 'alias_user_id': False,
- 'alias_model_id': cls.env['ir.model']._get('mail.test.cc').id,
- 'alias_contact': 'everyone'})
-
- cls.env['ir.config_parameter'].set_param('mail.bounce.alias', 'bounce.test')
- cls.env['ir.config_parameter'].set_param('mail.catchall.domain', 'test.com')
- cls.env['ir.config_parameter'].set_param('mail.catchall.alias', 'catchall.test')
-
- @mute_logger('odoo.addons.mail.models.mail_thread')
- def test_message_cc_new(self):
- record = self.format_and_process(MAIL_TEMPLATE, self.email_from, 'cc_record@test.com',
- cc='cc1@example.com, cc2@example.com', target_model='mail.test.cc')
- cc = email_split_and_format(record.email_cc)
- self.assertEqual(sorted(cc), ['cc1@example.com', 'cc2@example.com'])
-
- @mute_logger('odoo.addons.mail.models.mail_thread')
- def test_message_cc_update_with_old(self):
- record = self.env['mail.test.cc'].create({'email_cc': 'cc1 <cc1@example.com>, cc2@example.com'})
- self.alias.write({'alias_force_thread_id': record.id})
-
- self.format_and_process(MAIL_TEMPLATE, self.email_from, 'cc_record@test.com',
- cc='cc2 <cc2@example.com>, cc3@example.com', target_model='mail.test.cc')
- cc = email_split_and_format(record.email_cc)
- self.assertEqual(sorted(cc), ['cc1 <cc1@example.com>', 'cc2@example.com', 'cc3@example.com'], 'new cc should have been added on record (unique)')
-
- @mute_logger('odoo.addons.mail.models.mail_thread')
- def test_message_cc_update_no_old(self):
- record = self.env['mail.test.cc'].create({})
- self.alias.write({'alias_force_thread_id': record.id})
-
- self.format_and_process(MAIL_TEMPLATE, self.email_from, 'cc_record@test.com',
- cc='cc2 <cc2@example.com>, cc3@example.com', target_model='mail.test.cc')
- cc = email_split_and_format(record.email_cc)
- self.assertEqual(sorted(cc), ['cc2 <cc2@example.com>', 'cc3@example.com'], 'new cc should have been added on record (unique)')
-
- @mute_logger('odoo.addons.mail.models.mail_mail')
- def test_mail_cc_recipient_suggestion(self):
- record = self.env['mail.test.cc'].create({'email_cc': 'cc1@example.com, cc2@example.com, cc3 <cc3@example.com>'})
- suggestions = record._message_get_suggested_recipients()[record.id]
- self.assertEqual(sorted(suggestions), [
- (False, 'cc1@example.com', 'CC Email'),
- (False, 'cc2@example.com', 'CC Email'),
- (False, 'cc3 <cc3@example.com>', 'CC Email')
- ], 'cc should be in suggestions')
diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py
index 9848b26f0c7..52ed239bc0e 100644
--- a/addons/test_mail/tests/test_mail_gateway.py
+++ b/addons/test_mail/tests/test_mail_gateway.py
@@ -15,7 +15,7 @@ from odoo.addons.test_mail.models.test_mail_models import MailTestGateway
from odoo.addons.test_mail.tests.common import BaseFunctionalTest, MockEmails
from odoo.addons.test_mail.tests.common import mail_new_test_user
from odoo.tests import tagged
-from odoo.tools import mute_logger, pycompat
+from odoo.tools import email_split_and_format, mute_logger, pycompat
@tagged('mail_gateway')
@@ -113,9 +113,7 @@ class TestMailgateway(BaseFunctionalTest, MockEmails):
'message_id': '<123456-openerp-%s-mail.test.gateway@%s>' % (cls.test_record.id, socket.gethostname()),
})
- cls.env['ir.config_parameter'].set_param('mail.bounce.alias', 'bounce.test')
- cls.env['ir.config_parameter'].set_param('mail.catchall.domain', 'test.com')
- cls.env['ir.config_parameter'].set_param('mail.catchall.alias', 'catchall.test')
+ cls._init_mail_gateway()
# --------------------------------------------------
# Base low-level tests
@@ -748,3 +746,46 @@ class TestMailgateway(BaseFunctionalTest, MockEmails):
self.assertEqual(len(record), 1)
self.assertEqual(record.name, 'Spammy')
self.assertEqual(record._name, 'mail.test.gateway')
+
+
+class TestMailThreadCC(BaseFunctionalTest, MockEmails):
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestMailThreadCC, cls).setUpClass()
+
+ cls.email_from = 'Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>'
+ cls.alias = cls.env['mail.alias'].create({
+ 'alias_name': 'cc_record',
+ 'alias_user_id': False,
+ 'alias_model_id': cls.env['ir.model']._get('mail.test.cc').id,
+ 'alias_contact': 'everyone'})
+
+ cls._init_mail_gateway()
+
+ @mute_logger('odoo.addons.mail.models.mail_thread')
+ def test_message_cc_new(self):
+ record = self.format_and_process(MAIL_TEMPLATE, self.email_from, 'cc_record@test.com',
+ cc='cc1@example.com, cc2@example.com', target_model='mail.test.cc')
+ cc = email_split_and_format(record.email_cc)
+ self.assertEqual(sorted(cc), ['cc1@example.com', 'cc2@example.com'])
+
+ @mute_logger('odoo.addons.mail.models.mail_thread')
+ def test_message_cc_update_with_old(self):
+ record = self.env['mail.test.cc'].create({'email_cc': 'cc1 <cc1@example.com>, cc2@example.com'})
+ self.alias.write({'alias_force_thread_id': record.id})
+
+ self.format_and_process(MAIL_TEMPLATE, self.email_from, 'cc_record@test.com',
+ cc='cc2 <cc2@example.com>, cc3@example.com', target_model='mail.test.cc')
+ cc = email_split_and_format(record.email_cc)
+ self.assertEqual(sorted(cc), ['cc1 <cc1@example.com>', 'cc2@example.com', 'cc3@example.com'], 'new cc should have been added on record (unique)')
+
+ @mute_logger('odoo.addons.mail.models.mail_thread')
+ def test_message_cc_update_no_old(self):
+ record = self.env['mail.test.cc'].create({})
+ self.alias.write({'alias_force_thread_id': record.id})
+
+ self.format_and_process(MAIL_TEMPLATE, self.email_from, 'cc_record@test.com',
+ cc='cc2 <cc2@example.com>, cc3@example.com', target_model='mail.test.cc')
+ cc = email_split_and_format(record.email_cc)
+ self.assertEqual(sorted(cc), ['cc2 <cc2@example.com>', 'cc3@example.com'], 'new cc should have been added on record (unique)')