初始提交
This commit is contained in:
2
mail_enterprise/tests/__init__.py
Normal file
2
mail_enterprise/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import test_discuss_channel_expand
|
||||
from . import test_res_group_functional
|
||||
31
mail_enterprise/tests/test_discuss_channel_expand.py
Normal file
31
mail_enterprise/tests/test_discuss_channel_expand.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo.tests.common import tagged, HttpCase
|
||||
from odoo.addons.mail.tests.common import MailCommon
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
class TestDiscussChannelExpand(HttpCase, MailCommon):
|
||||
|
||||
def test_channel_expand_tour(self):
|
||||
testuser = self.env['res.users'].create({
|
||||
'email': 'testuser@testuser.com',
|
||||
'group_ids': [(6, 0, [self.ref('base.group_user')])],
|
||||
'name': 'Test User',
|
||||
'login': 'testuser',
|
||||
'password': 'testuser',
|
||||
})
|
||||
DiscussChannelAsUser = self.env['discuss.channel'].with_user(testuser)
|
||||
channel = DiscussChannelAsUser._create_channel(name="test-mail-channel-expand-tour", group_id=self.ref("base.group_user"))
|
||||
channel.message_post(
|
||||
body=Markup("<p>test-message-mail-channel-expand-tour</p>"),
|
||||
message_type='comment',
|
||||
subtype_xmlid='mail.mt_comment'
|
||||
)
|
||||
# clear all bus notifications, so that tour does not replay old notifications
|
||||
# on a more recent state with init_messaging
|
||||
self._reset_bus()
|
||||
self.start_tour("/odoo", 'mail_enterprise/static/tests/tours/discuss_channel_expand_test_tour.js', login='testuser')
|
||||
37
mail_enterprise/tests/test_res_group_functional.py
Normal file
37
mail_enterprise/tests/test_res_group_functional.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.mail.tests.common import MailCommon
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.tests.common import tagged
|
||||
|
||||
|
||||
@tagged("-at_install", "post_install")
|
||||
class TestResGroupFunctional(MailCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.group = cls.env["res.group.functional"].create({"name": "Test Group"})
|
||||
|
||||
def test_res_group_functional_add_responsible_member(self):
|
||||
"""Test that we add the responsible in the members list."""
|
||||
self.group.user_ids = self.user_employee
|
||||
self.group.responsible_ids = self.user_admin
|
||||
self.assertEqual(self.group.user_ids, self.user_employee | self.user_admin)
|
||||
|
||||
def test_res_group_functional_access_read(self):
|
||||
"""Test that any internal user can read the group."""
|
||||
self.env.invalidate_all()
|
||||
self.assertEqual(self.group.with_user(self.user_employee).name, "Test Group")
|
||||
|
||||
self.env.invalidate_all()
|
||||
with self.assertRaises(AccessError):
|
||||
self.assertEqual(self.group.with_user(self._create_portal_user()).name, "Test Group")
|
||||
|
||||
def test_res_group_functional_access_write(self):
|
||||
"""Test that only the responsibles and the admin can write on the group."""
|
||||
with self.assertRaises(AccessError):
|
||||
self.group.with_user(self.user_employee).name = "test 1"
|
||||
|
||||
self.group.responsible_ids = self.user_employee
|
||||
self.group.with_user(self.user_employee).name = "test 2"
|
||||
self.group.with_user(self.user_admin).name = "test 3"
|
||||
Reference in New Issue
Block a user