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.

34 lines
1.2 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 .common import Common
  6. class TestResGroups(Common):
  7. def test_can_write_max_users(self):
  8. """
  9. It should restrict membership additions to Threshold Managers to
  10. pre-existing members of that group
  11. """
  12. u = self._create_test_user()
  13. u.write({
  14. 'in_group_%s' % self.env.ref('base.group_erp_manager').id: True
  15. })
  16. g = self.env.ref('user_threshold.group_threshold_manager')
  17. with self.assertRaises(AccessError):
  18. g.sudo(u.id).write({'users': self.env.ref('base.user_demo').id})
  19. def test_cannot_write_max_users(self):
  20. """
  21. It should restrict membership additions to Threshold Managers to
  22. pre-existing members of that group
  23. """
  24. u = self._create_test_user()
  25. self._add_user_to_group(u)
  26. g = self.env.ref('user_threshold.group_threshold_manager')
  27. demo_user = self.env.ref('base.user_demo')
  28. g.sudo(u.id).write({'users': [(4, [demo_user.id])]})
  29. self.assertTrue(demo_user.id in g.users.ids)