diff --git a/addons/bus/tests/test_websocket_controller.py b/addons/bus/tests/test_websocket_controller.py index 3e4e4706082..0ff52979764 100644 --- a/addons/bus/tests/test_websocket_controller.py +++ b/addons/bus/tests/test_websocket_controller.py @@ -2,10 +2,11 @@ import json -from odoo.tests import common, JsonRpcException +from odoo.tests import JsonRpcException +from odoo.addons.base.tests.common import HttpCaseWithUserDemo -class TestWebsocketController(common.HttpCase): +class TestWebsocketController(HttpCaseWithUserDemo): def test_websocket_peek(self): result = self.make_jsonrpc_request('/websocket/peek_notifications', { 'channels': [], diff --git a/addons/im_livechat/tests/test_chatbot_form_ui.py b/addons/im_livechat/tests/test_chatbot_form_ui.py index 34088457f8d..c9749bf1517 100644 --- a/addons/im_livechat/tests/test_chatbot_form_ui.py +++ b/addons/im_livechat/tests/test_chatbot_form_ui.py @@ -2,10 +2,11 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import tests +from odoo.addons.base.tests.common import HttpCaseWithUserDemo @tests.tagged('post_install', '-at_install') -class TestLivechatChatbotFormUI(tests.HttpCase): +class TestLivechatChatbotFormUI(HttpCaseWithUserDemo): def test_chatbot_steps_sequence_ui(self): """ As sequences are *critical* for the chatbot_script script, let us a run a little tour that creates a few steps, then verify sequences are properly applied. """ diff --git a/addons/mail/tests/discuss/test_discuss_channel_as_guest.py b/addons/mail/tests/discuss/test_discuss_channel_as_guest.py index 9c8eefabc31..48f0d92fe98 100644 --- a/addons/mail/tests/discuss/test_discuss_channel_as_guest.py +++ b/addons/mail/tests/discuss/test_discuss_channel_as_guest.py @@ -1,11 +1,12 @@ # 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.tests.common import HttpCase, tagged +from odoo.tests.common import tagged +from odoo.addons.base.tests.common import HttpCaseWithUserPortal, HttpCaseWithUserDemo @tagged("post_install", "-at_install") -class TestMailPublicPage(HttpCase): +class TestMailPublicPage(HttpCaseWithUserPortal, HttpCaseWithUserDemo): """Checks that the invite page redirects to the channel and that all modules load correctly on the welcome and channel page when authenticated as various users""" diff --git a/addons/mail/tests/discuss/test_load_messages.py b/addons/mail/tests/discuss/test_load_messages.py index 5d0a151384b..3d183bdee06 100644 --- a/addons/mail/tests/discuss/test_load_messages.py +++ b/addons/mail/tests/discuss/test_load_messages.py @@ -1,10 +1,11 @@ import odoo.tests from odoo import Command +from odoo.addons.base.tests.common import HttpCaseWithUserDemo @odoo.tests.tagged('post_install', '-at_install') -class TestLoadMessages(odoo.tests.HttpCase): +class TestLoadMessages(HttpCaseWithUserDemo): def test_01_mail_message_load_order_tour(self): partner_admin = self.env.ref('base.partner_admin') channel_id = self.env["discuss.channel"].create({ diff --git a/addons/mail/tests/discuss/test_message_controller.py b/addons/mail/tests/discuss/test_message_controller.py index 216174db6eb..eb36236a274 100644 --- a/addons/mail/tests/discuss/test_message_controller.py +++ b/addons/mail/tests/discuss/test_message_controller.py @@ -4,13 +4,13 @@ import json import odoo from odoo.tools import mute_logger, date_utils -from odoo.tests import HttpCase +from odoo.addons.base.tests.common import HttpCaseWithUserDemo from odoo.http import STATIC_CACHE_LONG from odoo import Command @odoo.tests.tagged("-at_install", "post_install") -class TestMessageController(HttpCase): +class TestMessageController(HttpCaseWithUserDemo): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/addons/mail/tests/discuss/test_ui.py b/addons/mail/tests/discuss/test_ui.py index 224c673a41e..c44531368a2 100644 --- a/addons/mail/tests/discuss/test_ui.py +++ b/addons/mail/tests/discuss/test_ui.py @@ -2,10 +2,11 @@ import odoo.tests from odoo import Command +from odoo.addons.base.tests.common import HttpCaseWithUserDemo @odoo.tests.tagged('post_install', '-at_install') -class TestUi(odoo.tests.HttpCase): +class TestUi(HttpCaseWithUserDemo): def test_01_mail_tour(self): self.start_tour("/web", 'discuss_channel_tour', login="admin") diff --git a/addons/mail/tests/test_res_users.py b/addons/mail/tests/test_res_users.py index 355c0924c17..3cfb5bc151c 100644 --- a/addons/mail/tests/test_res_users.py +++ b/addons/mail/tests/test_res_users.py @@ -7,7 +7,8 @@ from unittest.mock import patch from odoo import Command from odoo.addons.base.models.res_users import Users from odoo.addons.mail.tests.common import MailCommon, mail_new_test_user -from odoo.tests import HttpCase, tagged, users +from odoo.addons.base.tests.common import HttpCaseWithUserDemo +from odoo.tests import tagged, users from odoo.tools import mute_logger @@ -82,7 +83,7 @@ class TestUser(MailCommon): @tagged('-at_install', 'post_install') -class TestUserModifyOwnProfile(HttpCase): +class TestUserModifyOwnProfile(HttpCaseWithUserDemo): def test_user_modify_own_profile(self): """" A user should be able to modify their own profile. diff --git a/addons/test_discuss_full/tests/test_performance.py b/addons/test_discuss_full/tests/test_performance.py index 5deb72b746d..6ab624c735d 100644 --- a/addons/test_discuss_full/tests/test_performance.py +++ b/addons/test_discuss_full/tests/test_performance.py @@ -18,6 +18,11 @@ class TestDiscussFullPerformance(HttpCase): super().setUp() self.group_user = self.env.ref('base.group_user') self.password = 'Pl1bhD@2!kXZ' + self.env['mail.shortcode'].search([]).unlink() + self.shortcodes = self.env['mail.shortcode'].create([ + {'source': 'hello', 'substitution': 'Hello, how may I help you?'}, + {'source': 'bye', 'substitution': 'Thanks for your feedback. Goodbye!'}, + ]) self.users = self.env['res.users'].create([ { 'email': 'e.e@example.com', @@ -64,6 +69,7 @@ class TestDiscussFullPerformance(HttpCase): def test_init_messaging(self): """Test performance of `_init_messaging`.""" self.channel_general = self.env.ref('mail.channel_all_employees') # Unfortunately #general cannot be deleted. Assertions below assume data from a fresh db with demo. + self.channel_general.message_ids.unlink() # Remove messages to avoid depending on demo data. self.env['discuss.channel'].sudo().search([('id', '!=', self.channel_general.id)]).unlink() self.user_root = self.env.ref('base.user_root') # create public channels @@ -163,7 +169,7 @@ class TestDiscussFullPerformance(HttpCase): 'custom_channel_name': False, 'id': self.channel_general.id, 'memberCount': len(self.group_user.users), - 'message_unread_counter': 5, + 'message_unread_counter': 0, 'model': "discuss.channel", 'create_uid': self.user_root.id, 'defaultDisplayMode': False, @@ -1007,12 +1013,12 @@ class TestDiscussFullPerformance(HttpCase): 'companyName': 'YourCompany', 'shortcodes': [ { - 'id': 1, + 'id': self.shortcodes[0].id, 'source': 'hello', 'substitution': 'Hello, how may I help you?', }, { - 'id': 2, + 'id': self.shortcodes[1].id, 'source': 'bye', 'substitution': 'Thanks for your feedback. Goodbye!', }, diff --git a/addons/website_livechat/tests/common.py b/addons/website_livechat/tests/common.py index 2703dbb3fde..db7aefc3ad4 100644 --- a/addons/website_livechat/tests/common.py +++ b/addons/website_livechat/tests/common.py @@ -3,12 +3,14 @@ import random -from odoo import fields, tests +from odoo import fields +from odoo.addons.base.tests.common import TransactionCaseWithUserDemo -class TestLivechatCommon(tests.TransactionCase): +class TestLivechatCommon(TransactionCaseWithUserDemo): def setUp(self): super(TestLivechatCommon, self).setUp() + self.env.ref("base.main_partner").email = "info@mycompany.com" self.base_datetime = fields.Datetime.from_string("2019-11-11 21:30:00") self.group_user = self.env.ref('base.group_user') @@ -40,8 +42,8 @@ class TestLivechatCommon(tests.TransactionCase): 'lang_id': self.env.ref('base.lang_en').id, 'country_id': self.env.ref('base.de').id, 'website_id': self.env.ref('website.default_website').id, - 'partner_id': self.env.ref('base.user_demo').partner_id.id, - 'access_token': self.env.ref('base.user_demo').partner_id.id, + 'partner_id': self.partner_demo.id, + 'access_token': self.partner_demo.id, }] + [ dict(visitor_vals, access_token='%032x' % random.randrange(16**32)) for _ in range(self.max_sessions_per_operator) diff --git a/addons/website_livechat/tests/test_livechat_basic_flow.py b/addons/website_livechat/tests/test_livechat_basic_flow.py index 3e5a021520d..40e6f04b5cf 100644 --- a/addons/website_livechat/tests/test_livechat_basic_flow.py +++ b/addons/website_livechat/tests/test_livechat_basic_flow.py @@ -4,12 +4,13 @@ import datetime from odoo import tests, _ +from odoo.addons.base.tests.common import HttpCaseWithUserDemo from odoo.addons.website_livechat.tests.common import TestLivechatCommon from odoo.tests.common import new_test_user @tests.tagged('post_install', '-at_install') -class TestLivechatBasicFlowHttpCase(tests.HttpCase, TestLivechatCommon): +class TestLivechatBasicFlowHttpCase(HttpCaseWithUserDemo, TestLivechatCommon): def test_channel_created_on_user_interaction(self): self.start_tour('/', 'im_livechat_request_chat', login=None) channel = self.env['discuss.channel'].search([['livechat_active', '=', True], ['livechat_visitor_id', '=', self.visitor.id]]) diff --git a/addons/website_livechat/tests/test_livechat_request.py b/addons/website_livechat/tests/test_livechat_request.py index fae6fee6555..a7ea3cb9448 100644 --- a/addons/website_livechat/tests/test_livechat_request.py +++ b/addons/website_livechat/tests/test_livechat_request.py @@ -2,11 +2,12 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import tests +from odoo.addons.base.tests.common import HttpCaseWithUserDemo from odoo.addons.website_livechat.tests.common import TestLivechatCommon @tests.tagged('post_install', '-at_install') -class TestLivechatRequestHttpCase(tests.HttpCase, TestLivechatCommon): +class TestLivechatRequestHttpCase(HttpCaseWithUserDemo, TestLivechatCommon): def test_livechat_request_complete_flow(self): self._clean_livechat_sessions() diff --git a/addons/website_livechat/tests/test_ui.py b/addons/website_livechat/tests/test_ui.py index bd96b6071ae..8627ee1b686 100644 --- a/addons/website_livechat/tests/test_ui.py +++ b/addons/website_livechat/tests/test_ui.py @@ -2,11 +2,12 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import tests, _ +from odoo.addons.base.tests.common import HttpCaseWithUserDemo from odoo.addons.website_livechat.tests.common import TestLivechatCommon @tests.tagged('post_install', '-at_install') -class TestLivechatUI(tests.HttpCase, TestLivechatCommon): +class TestLivechatUI(HttpCaseWithUserDemo, TestLivechatCommon): def setUp(self): super(TestLivechatUI, self).setUp() self.visitor_tour = self.env['website.visitor'].create({