File: test_discuss_message_update_controller.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (51 lines) | stat: -rw-r--r-- 1,955 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import odoo
from odoo.addons.mail.tests.test_message_update_controller import TestMessageUpdateControllerCommon


@odoo.tests.tagged("-at_install", "post_install")
class TestDiscussMessageUpdateController(TestMessageUpdateControllerCommon):
    def test_message_update_guest_as_owner(self):
        """Test only admin user and message author can update the message content in a channel."""
        channel = self.env["discuss.channel"].create(
            {"group_public_id": None, "name": "public channel"}
        )
        channel.add_members(guest_ids=[self.guest.id])
        channel.env.context = {**channel.env.context, "guest": self.guest}
        message = channel.with_user(self.user_public).message_post(
            body=self.message_body,
            message_type="comment",
        )
        self._execute_subtests(
            message,
            (
                (self.guest, True),
                (self.user_admin, True),
                (self.user_demo, False),
                (self.user_employee, False),
                (self.user_portal, False),
                (self.user_public, False),
            ),
        )

    def test_message_update_public_channel(self):
        """Test only admin user can update the message content of other authors in a channel."""
        channel = self.env["discuss.channel"].create(
            {"group_public_id": None, "name": "public channel"}
        )
        message = channel.message_post(
            body=self.message_body,
            message_type="comment",
        )
        self._execute_subtests(
            message,
            (
                (self.guest, False),
                (self.user_admin, True),
                (self.user_demo, False),
                (self.user_employee, False),
                (self.user_portal, False),
                (self.user_public, False),
            ),
        )