diff --git a/web_notify_channel_message/__manifest__.py b/web_notify_channel_message/__manifest__.py index 0c0a79d91..050c2d74e 100644 --- a/web_notify_channel_message/__manifest__.py +++ b/web_notify_channel_message/__manifest__.py @@ -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", diff --git a/web_notify_channel_message/tests/__init__.py b/web_notify_channel_message/tests/__init__.py new file mode 100644 index 000000000..8c59b263e --- /dev/null +++ b/web_notify_channel_message/tests/__init__.py @@ -0,0 +1 @@ +from . import test_notify_channel_message diff --git a/web_notify_channel_message/tests/test_notify_channel_message.py b/web_notify_channel_message/tests/test_notify_channel_message.py new file mode 100644 index 000000000..edaec369c --- /dev/null +++ b/web_notify_channel_message/tests/test_notify_channel_message.py @@ -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)