def _add_admin_object_permission(self):
        endpoint = self.permission_tests['endpoint'].format(self.obj.pk)
        endpoint += 'permissions/users/'

        self.client.login(username='test.admin', password='1234')

        # Grant permissions to test.user via the API (but poorly - test to make sure
        # there is an array or perms)
        response = self.client.post(endpoint, {'user': 'test.user', 'permissions': 'admin'})
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        # Now actually grant permissions
        response = self.client.post(endpoint, {'user': 'test.user', 'permissions': ['admin']})
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Make sure the user now has admin permissions
        self.assertTrue(self.user.has_perm(self.permission_tests['permission'] % 'admin', self.obj))

        self.client.login(username='test.user', password='1234')
dataset/ETHPy150Open stackdio/stackdio/stackdio/core/tests/utils.py/PermissionsMixin._add_admin_object_permission/original