def test_partial_update_object_permissions(self):
        orig_endpoint = self.permission_tests['endpoint'].format(self.obj.pk)
        endpoint = orig_endpoint + 'permissions/users/test.user/'

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

        # Try hitting the user permissions endpoint
        response = self.client.put(endpoint, {'user': 'test.user', 'permissions': 'blah'})
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

        # Add admin permission
        self._add_admin_object_permission()

        # Now try again with permissions, but try with an invalid permission
        response = self.client.put(endpoint, {'user': 'test.user', 'permissions': ['blah']})
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        # Now try updating for real
        response = self.client.patch(endpoint, {'user': 'test.user', 'permissions': ['view']})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTrue(self.user.has_perm('view' % self.permission_tests['permission'], self.obj))

        # Try grabbing the object
        response = self.client.get(orig_endpoint)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Make sure the endpoint properly shows the permissions
        response = self.client.get(endpoint)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['permissions'], ['admin', 'view'])
dataset/ETHPy150Open stackdio/stackdio/stackdio/core/tests/utils.py/PermissionsMixin.test_partial_update_object_permissions/swapped operands of `%`