Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,72 @@
# 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().setUpClass()
cls.env.user = cls.env.ref("base.user_admin")
cls.other_user = cls.env.ref("base.user_demo")
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["discuss.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_admin(self):
initial_message = (
self.env["discuss.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["discuss.channel"]
.search([("name", "=", "Test channel")], limit=1)
.message_ids[0]
)
self.assertEqual(len(message), 1)
def test_02_post_message_non_admin(self):
initial_message = (
self.env["discuss.channel"]
.search([("name", "=", "Test channel")], limit=1)
.message_ids
)
self.assertEqual(len(initial_message), 0)
self.channel.with_user(self.other_user).message_post(
author_id=self.other_user.partner_id.id,
body="Hello",
message_type="notification",
subtype_xmlid="mail.mt_comment",
)
message = (
self.env["discuss.channel"]
.search([("name", "=", "Test channel")], limit=1)
.message_ids[0]
)
self.assertEqual(len(message), 1)