def test_user_delete_errors(staff_user, customer_user, admin_user): info = Mock(context=Mock(user=staff_user)) errors = UserDelete.clean_instance(info, staff_user, []) assert errors[0].field == 'id' assert errors[0].message == 'You cannot delete your own account.' info = Mock(context=Mock(user=staff_user)) errors = UserDelete.clean_instance(info, admin_user, []) assert errors[0].field == 'id' assert errors[0].message == 'Only superuser can delete his own account.'
def test_user_delete_errors(staff_user, admin_user): info = Mock(context=Mock(user=staff_user)) errors = [] UserDelete.clean_instance(info, staff_user, errors) assert errors[0].field == 'id' assert errors[0].message == 'You cannot delete your own account.' info = Mock(context=Mock(user=staff_user)) errors = [] UserDelete.clean_instance(info, admin_user, errors) assert errors[0].field == 'id' assert errors[0].message == 'Cannot delete this account.'