def test_group_manager_assign(self):
        manager = GroupObjectPermissionManager()
        manager.assign_perm = mock.Mock()

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")

            manager.assign('perm', 'group', 'object')

        manager.assign_perm.assert_called_once_with('perm', 'group', 'object')

        self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        self.assertIn("UserObjectPermissionManager method 'assign' is being renamed to 'assign_perm'.", str(w[0].message))
    def test_group_manager_assign(self):
        manager = GroupObjectPermissionManager()
        manager.assign_perm = mock.Mock()

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")

            manager.assign('perm', 'group', 'object')

        manager.assign_perm.assert_called_once_with('perm', 'group', 'object')

        self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        self.assertIn("UserObjectPermissionManager method 'assign' is being renamed to 'assign_perm'.", str(w[0].message))
Esempio n. 3
0
class GroupObjectPermission(BaseObjectPermission):
    """
    **Manager**: :manager:`GroupObjectPermissionManager`
    """
    group = models.ForeignKey(Group)

    objects = GroupObjectPermissionManager()

    class Meta:
        unique_together = ['group', 'permission', 'content_type', 'object_pk']
Esempio n. 4
0
class GroupObjectPermissionBase(BaseObjectPermission):
    """
    **Manager**: :manager:`GroupObjectPermissionManager`
    """
    group = models.ForeignKey(Group, on_delete=models.CASCADE)

    objects = GroupObjectPermissionManager()

    class Meta:
        abstract = True
        unique_together = ['group', 'permission', 'content_object']
Esempio n. 5
0
 def test_group_manager_assign(self):
     manager = GroupObjectPermissionManager()
     manager.assign_perm = mock.Mock()
     manager.assign('perm', 'group', 'object')
     manager.assign_perm.assert_called_once_with('perm', 'group', 'object')
Esempio n. 6
0
 def test_group_manager_assign(self):
     manager = GroupObjectPermissionManager()
     manager.assign_perm = mock.Mock()
     manager.assign("perm", "group", "object")
     manager.assign_perm.assert_called_once_with("perm", "group", "object")
Esempio n. 7
0
 def test_group_manager_assign(self):
     manager = GroupObjectPermissionManager()
     manager.assign_perm = mock.Mock()
     manager.assign('perm', 'group', 'object')
     manager.assign_perm.assert_called_once_with('perm', 'group', 'object')