[FIX] test_discuss_full, *: decouple tests from demo data dependency

*: website_livechat.

closes odoo/odoo#143645

X-original-commit: 9643717d911c31f150adab5b699ec7b9219f8981
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit is contained in:
tsm-odoo
2023-11-27 08:39:49 +00:00
parent 33e837d429
commit 8e52f40f59
12 changed files with 38 additions and 21 deletions
@@ -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': [],
@@ -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. """
@@ -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"""
@@ -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({
@@ -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()
+2 -1
View File
@@ -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")
+3 -2
View File
@@ -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.
@@ -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!',
},
+6 -4
View File
@@ -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)
@@ -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]])
@@ -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()
+2 -1
View File
@@ -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({