'User can delete page permissions if he has
change permissions on the Page model,
delete permissions on the PagePermission model,
global change permission and global change permissions permission.'

def test_user_can_delete_page_permissions(self):

    admin = self.get_superuser()
    page = self.get_permissions_test_page()
    endpoint = (self.get_admin_url(Page, 'permissions', page.pk) + '?language=en')
    staff_user = self.get_staff_user_with_no_permissions()
    staff_user_2 = self.get_staff_page_user(created_by=admin)
    permission = self.add_page_permission(user=staff_user_2, page=page)
    data = self._get_page_permissions_data(page=page.pk, user=staff_user_2.pk, id=permission.pk, DELETE='on')
    data['_continue'] = '1'
    self.add_permission(staff_user, 'change_page')
    self.add_permission(staff_user, 'delete_pagepermission')
    self.add_global_permission(staff_user, can_change=True, can_change_permissions=True)
    with self.login_user_context(staff_user):
        response = self.client.post(endpoint, data)
        self.assertEqual(response.status_code, 302)
        self.assertRedirects(response, endpoint)
        self.assertFalse(self._page_permission_exists(user=staff_user_2))
