[MIG] web_notify_channel_message: Migration to 16.0

pull/2543/head
DavidJForgeFlow 2023-06-27 12:43:38 +02:00
parent b1fa67c58b
commit 08b827c7f3
3 changed files with 53 additions and 1 deletions

View File

@ -6,7 +6,7 @@
"name": "Web Notify Channel Message",
"summary": """
Send an instant notification to channel users when a new message is posted""",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"development_status": "Alpha",

View File

@ -0,0 +1 @@
from . import test_notify_channel_message

View File

@ -0,0 +1,51 @@
# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import api
from odoo.tests import common
class TestWebNotifyChannelMessage(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestWebNotifyChannelMessage, cls).setUpClass()
cls.env.user = cls.env.ref("base.user_admin")
cls.env = api.Environment(cls.cr, cls.env.user.id, {})
cls.env.user.tz = False # Make sure there's no timezone in user
cls.user_internal = cls.env["res.users"].create(
{
"name": "Test Internal User",
"login": "internal_user",
"password": "internal_user",
"email": "mark.brown23@example.com",
}
)
cls.channel = cls.env["mail.channel"].create(
{
"name": "Test channel",
"channel_partner_ids": [
(4, cls.env.user.partner_id.id),
(4, cls.user_internal.partner_id.id),
],
}
)
def test_01_post_message(self):
initial_message = (
self.env["mail.channel"]
.search([("name", "=", "Test channel")], limit=1)
.message_ids
)
self.assertEqual(len(initial_message), 0)
self.channel.message_post(
author_id=self.env.user.partner_id.id,
body="Hello",
message_type="notification",
subtype_xmlid="mail.mt_comment",
)
message = (
self.env["mail.channel"]
.search([("name", "=", "Test channel")], limit=1)
.message_ids[0]
)
self.assertEqual(len(message), 1)