[REF] test_mail(_*): simplify Mail-based test class usage

'TestMailCommon' was useless and is replaced by the 'MailCommon' class defined
directly in Mail addon, easing inheritance and imports.

Task-3263512

Part-of: odoo/odoo#117606
This commit is contained in:
Thibault Delavallée
2023-04-04 20:08:37 +02:00
parent 826fee8b02
commit c9848bbf58
19 changed files with 66 additions and 65 deletions
-6
View File
@@ -1,15 +1,9 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.mail.tests.common import MailCommon
from odoo.tests.common import TransactionCase
class TestMailCommon(MailCommon):
""" Main entry point for functional tests. Kept to ease backward
compatibility. """
class TestRecipients(TransactionCase):
@classmethod
+2 -2
View File
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import MailCommon
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('mail_followers')
class TestInvite(TestMailCommon):
class TestInvite(MailCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_invite_email(self):
+2 -2
View File
@@ -2,13 +2,13 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.base.tests.test_ir_actions import TestServerActionsBase
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import MailCommon
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('ir_actions')
class TestServerActionsEmail(TestMailCommon, TestServerActionsBase):
class TestServerActionsEmail(MailCommon, TestServerActionsBase):
def setUp(self):
super(TestServerActionsEmail, self).setUp()
+2 -3
View File
@@ -11,14 +11,13 @@ from unittest.mock import DEFAULT
import pytz
from odoo import fields, exceptions, tests
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import mail_new_test_user, MailCommon
from odoo.addons.test_mail.models.test_mail_models import MailTestActivity
from odoo.tools import mute_logger
from odoo.tests.common import Form, users
class TestActivityCommon(TestMailCommon):
class TestActivityCommon(MailCommon):
@classmethod
def setUpClass(cls):
+3 -3
View File
@@ -10,10 +10,10 @@ from itertools import product
from unittest.mock import DEFAULT, patch
from odoo.addons.base.tests.test_ir_cron import CronMixinCase
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.mail.tests.common import mail_new_test_user, MailCommon
from odoo.addons.mail.wizard.mail_compose_message import MailComposer
from odoo.addons.test_mail.models.test_mail_models import MailTestTicket
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.fields import Datetime as FieldDatetime
from odoo.exceptions import AccessError
from odoo.tests import tagged
@@ -22,7 +22,7 @@ from odoo.tools import mute_logger, formataddr
@tagged('mail_composer')
class TestMailComposer(TestMailCommon, TestRecipients):
class TestMailComposer(MailCommon, TestRecipients):
""" Test Composer internals """
@classmethod
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.mail.tests.common import MailCommon
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.tests import tagged
from odoo.tests.common import users
@tagged('mail_composer_mixin')
class TestMailComposerMixin(TestMailCommon, TestRecipients):
class TestMailComposerMixin(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import MailCommon
from odoo.exceptions import AccessError
from odoo.tests import tagged, users
from odoo.tools import mute_logger
@tagged('mail_followers')
class BaseFollowersTest(TestMailCommon):
class BaseFollowersTest(MailCommon):
@classmethod
def setUpClass(cls):
@@ -229,7 +229,7 @@ class BaseFollowersTest(TestMailCommon):
@tagged('mail_followers')
class AdvancedFollowersTest(TestMailCommon):
class AdvancedFollowersTest(MailCommon):
@classmethod
def setUpClass(cls):
@@ -440,7 +440,9 @@ class AdvancedFollowersTest(TestMailCommon):
)
class AdvancedResponsibleNotifiedTest(TestMailCommon):
@tagged('mail_followers')
class AdvancedResponsibleNotifiedTest(MailCommon):
def setUp(self):
super(AdvancedResponsibleNotifiedTest, self).setUp()
@@ -486,7 +488,7 @@ class AdvancedResponsibleNotifiedTest(TestMailCommon):
@tagged('mail_followers', 'post_install', '-at_install')
class RecipientsNotificationTest(TestMailCommon):
class RecipientsNotificationTest(MailCommon):
""" Test advanced and complex recipients computation / notification, such
as multiple users, batch computation, ... Post install because we need the
registry to be ready to send notifications."""
+7 -7
View File
@@ -9,11 +9,10 @@ from unittest.mock import DEFAULT
from unittest.mock import patch
from odoo import exceptions
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.mail.tests.common import mail_new_test_user, MailCommon
from odoo.addons.test_mail.data import test_mail_data
from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE
from odoo.addons.test_mail.models.test_mail_models import MailTestGateway
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.sql_db import Cursor
from odoo.tests import tagged
from odoo.tests.common import users
@@ -21,7 +20,7 @@ from odoo.tools import email_split_and_format, formataddr, mute_logger
@tagged('mail_gateway')
class TestEmailParsing(TestMailCommon):
class TestEmailParsing(MailCommon):
def test_message_parse_and_replace_binary_octetstream(self):
""" Incoming email containing a wrong Content-Type as described in RFC2046/section-3 """
@@ -140,7 +139,7 @@ class TestEmailParsing(TestMailCommon):
self.env['mail.thread'].message_parse(self.from_string(test_mail_data.MAIL_XHTML))
@tagged('mail_gateway')
class TestMailAlias(TestMailCommon):
class TestMailAlias(MailCommon):
@users('employee')
@mute_logger('odoo.addons.base.models.ir_model')
@@ -234,7 +233,7 @@ class TestMailAlias(TestMailCommon):
@tagged('mail_gateway')
class TestMailAliasMixin(TestMailCommon):
class TestMailAliasMixin(MailCommon):
@users('employee')
def test_alias_mixin_copy_content(self):
@@ -258,7 +257,7 @@ class TestMailAliasMixin(TestMailCommon):
@tagged('mail_gateway')
class TestMailgateway(TestMailCommon):
class TestMailgateway(MailCommon):
@classmethod
def setUpClass(cls):
@@ -1684,7 +1683,8 @@ class TestMailgateway(TestMailCommon):
self.assertEqual(len(records), 10, msg='Email whitelisted should not have the restriction')
class TestMailThreadCC(TestMailCommon):
@tagged('mail_gateway')
class TestMailThreadCC(MailCommon):
@classmethod
def setUpClass(cls):
+2 -2
View File
@@ -13,14 +13,14 @@ from unittest.mock import call, patch
from odoo import api, Command
from odoo.addons.base.models.ir_mail_server import MailDeliveryException
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import MailCommon
from odoo.exceptions import AccessError
from odoo.tests import common, tagged, users
from odoo.tools import mute_logger, DEFAULT_SERVER_DATETIME_FORMAT
@tagged('mail_mail')
class TestMailMail(TestMailCommon):
class TestMailMail(MailCommon):
@classmethod
def setUpClass(cls):
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.mail.tests.common import MailCommon
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.tests import tagged
@tagged('mail_management')
class TestMailManagement(TestMailCommon, TestRecipients):
class TestMailManagement(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
+3 -4
View File
@@ -4,8 +4,7 @@
import base64
from unittest.mock import patch
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import mail_new_test_user, MailCommon
from odoo.addons.test_mail.models.test_mail_models import MailTestSimple
from odoo.exceptions import AccessError, UserError
from odoo.tools import is_html_empty, mute_logger, formataddr
@@ -13,7 +12,7 @@ from odoo.tests import tagged, users
@tagged('mail_message')
class TestMessageValues(TestMailCommon):
class TestMessageValues(MailCommon):
@classmethod
def setUpClass(cls):
@@ -321,7 +320,7 @@ class TestMessageValues(TestMailCommon):
@tagged('mail_message')
class TestMessageAccess(TestMailCommon):
class TestMessageAccess(MailCommon):
@classmethod
def setUpClass(cls):
@@ -9,7 +9,8 @@ from unittest.mock import patch
from werkzeug.urls import url_parse, url_decode
from odoo.addons.mail.models.mail_message import Message
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.mail.tests.common import MailCommon
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.exceptions import AccessError
from odoo.tests import tagged
from odoo.tests.common import users, HttpCase
@@ -17,7 +18,7 @@ from odoo.tools import formataddr, mute_logger
@tagged('multi_company')
class TestMultiCompanySetup(TestMailCommon, TestRecipients):
class TestMultiCompanySetup(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
@@ -384,7 +385,7 @@ class TestMultiCompanySetup(TestMailCommon, TestRecipients):
@tagged('-at_install', 'post_install', 'multi_company')
class TestMultiCompanyRedirect(TestMailCommon, HttpCase):
class TestMultiCompanyRedirect(MailCommon, HttpCase):
@classmethod
def setUpClass(cls):
+3 -2
View File
@@ -6,12 +6,13 @@ import datetime
from freezegun import freeze_time
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.mail.tests.common import MailCommon
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.tests import tagged, users
from odoo.tools import mute_logger
class TestMailTemplateCommon(TestMailCommon, TestRecipients):
class TestMailTemplateCommon(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
@@ -5,14 +5,15 @@ from unittest.mock import patch
from unittest.mock import DEFAULT
from odoo import exceptions
from odoo.addons.mail.tests.common import MailCommon
from odoo.addons.test_mail.models.test_mail_models import MailTestSimple
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.tests.common import tagged, Form, users
from odoo.tools import mute_logger
@tagged('mail_thread')
class TestAPI(TestMailCommon, TestRecipients):
class TestAPI(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
@@ -99,7 +100,7 @@ class TestAPI(TestMailCommon, TestRecipients):
@tagged('mail_thread')
class TestChatterTweaks(TestMailCommon, TestRecipients):
class TestChatterTweaks(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
@@ -199,7 +200,7 @@ class TestChatterTweaks(TestMailCommon, TestRecipients):
@tagged('mail_thread')
class TestDiscuss(TestMailCommon, TestRecipients):
class TestDiscuss(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
@@ -399,7 +400,7 @@ class TestDiscuss(TestMailCommon, TestRecipients):
@tagged('mail_thread')
class TestNoThread(TestMailCommon, TestRecipients):
class TestNoThread(MailCommon, TestRecipients):
""" Specific tests for cross models thread features """
@users('employee')
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import mail_new_test_user, MailCommon
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('mail_wizards')
class TestMailResend(TestMailCommon):
class TestMailResend(MailCommon):
@classmethod
def setUpClass(cls):
+4 -4
View File
@@ -11,10 +11,10 @@ from unittest.mock import patch
from odoo import tools
from odoo.addons.base.tests.test_ir_cron import CronMixinCase
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.mail.tests.common import mail_new_test_user, MailCommon
from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE_PLAINTEXT
from odoo.addons.test_mail.models.test_mail_models import MailTestSimple
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.api import call_kw
from odoo.exceptions import AccessError
from odoo.tests import tagged
@@ -22,7 +22,7 @@ from odoo.tools import mute_logger, formataddr
from odoo.tests.common import users
class TestMessagePostCommon(TestMailCommon, TestRecipients):
class TestMessagePostCommon(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
@@ -1525,7 +1525,7 @@ class TestMessagePostGlobal(TestMessagePostCommon):
@tagged('mail_post', 'multi_lang')
class TestMessagePostLang(TestMailCommon, TestRecipients):
class TestMessagePostLang(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
+5 -4
View File
@@ -3,13 +3,13 @@
from unittest.mock import patch
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.addons.mail.tests.common import MailCommon
from odoo.tests.common import tagged
from odoo.tests import Form
@tagged('mail_track')
class TestTracking(TestMailCommon):
class TestTracking(MailCommon):
def setUp(self):
super(TestTracking, self).setUp()
@@ -315,7 +315,7 @@ class TestTracking(TestMailCommon):
])
@tagged('mail_track')
class TestTrackingMonetary(TestMailCommon):
class TestTrackingMonetary(MailCommon):
def setUp(self):
super(TestTrackingMonetary, self).setUp()
@@ -355,8 +355,9 @@ class TestTrackingMonetary(TestMailCommon):
('company_currency', 'many2one', self.user_employee.company_id.currency_id, self.company_2.currency_id)
])
@tagged('mail_track')
class TestTrackingInternals(TestMailCommon):
class TestTrackingInternals(MailCommon):
def setUp(self):
super(TestTrackingInternals, self).setUp()
+3 -2
View File
@@ -3,13 +3,14 @@
from unittest.mock import patch
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.mail.tests.common import MailCommon
from odoo.addons.test_mail.tests.common import TestRecipients
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged("odoobot")
class TestOdoobot(TestMailCommon, TestRecipients):
class TestOdoobot(MailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
+5 -4
View File
@@ -3,12 +3,13 @@
from odoo.addons.phone_validation.tools import phone_validation
from odoo.addons.sms.tests.common import SMSCommon
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.mail.tests.common import MailCommon
from odoo.addons.test_mail.tests.common import TestRecipients
class TestSMSCommon(SMSCommon, TestMailCommon):
""" Main entry point for functional tests. Kept to ease backward
compatibility and updating common. """
class TestSMSCommon(SMSCommon, MailCommon):
""" Main entry point for functional tests. It combines both SMS and MAIL
testing classes. """
class TestSMSRecipients(TestRecipients):