[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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
@@ -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)')
|
||||
|
||||
Reference in New Issue
Block a user