You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html
  4. from odoo.exceptions import AccessError
  5. from odoo.tests import TransactionCase
  6. class TestResGroups(TransactionCase):
  7. def setUp(self):
  8. super(TestResGroups, self).setUp()
  9. self.immutable = self.env.ref('user_immutable.group_immutable')
  10. self.user = self.env.ref('base.user_demo')
  11. self.user.write({'in_group_%s' % self.immutable.id: False})
  12. def test_can_add_immutable(self):
  13. """ It should make sure that `Administrator` can add users to the
  14. immutable group by default """
  15. self.immutable.write({'users': [(4, [self.user.id])]})
  16. self.assertTrue(self.user.has_group('user_immutable.group_immutable'))
  17. def test_non_immutable_cannot_add_immutable(self):
  18. """ It should make sure that other users cannot add to the immutable
  19. group """
  20. immutable = self.env.ref('user_immutable.group_immutable')
  21. with self.assertRaises(AccessError):
  22. immutable.sudo(self.user.id).write({'users': [self.user.id]})