def METHOD_NAME(
        rotkehlchen_api_server: APIServer,
        data_dir: Path,
        username: str,
):
    """Test that errors are handled properly in backup deletion and download"""
    user_data_dir = Path(data_dir, username)
    # Make sure deleting file outside  of user data dir fails
    undeletable_file = Path(data_dir / 'notdeletablefile')
    undeletable_file.touch()
    assert undeletable_file.exists()
    response = requests.delete(
        api_url_for(
            rotkehlchen_api_server,
            'databasebackupsresource'),
        json={'files': [str(undeletable_file)]},
    )
    assert_error_response(
        response=response,
        contained_in_msg='is not in the user directory',
        status_code=HTTPStatus.CONFLICT,
    )
    response = requests.get(
        api_url_for(
            rotkehlchen_api_server,
            'databasebackupsresource'),
        json={'file': str(undeletable_file)},
    )
    assert_error_response(
        response=response,
        contained_in_msg='is not in the user directory',
        status_code=HTTPStatus.CONFLICT,
    )
    undeletable_file.unlink()  # finally delete normally
    response = requests.delete(
        api_url_for(
            rotkehlchen_api_server,
            'databasebackupsresource'),
        json={'files': [str(Path(user_data_dir, 'idontexist'))]},
    )
    assert_error_response(
        response=response,
        contained_in_msg='does not exist',
        status_code=HTTPStatus.BAD_REQUEST,
    )
    response = requests.get(
        api_url_for(
            rotkehlchen_api_server,
            'databasebackupsresource'),
        json={'file': str(Path(user_data_dir, 'idontexist'))},
    )
    assert_error_response(
        response=response,
        contained_in_msg='does not exist',
        status_code=HTTPStatus.BAD_REQUEST,
    )
    # test delete two files and only one exists
    undeletable_file.touch()
    response = requests.put(api_url_for(rotkehlchen_api_server, 'databasebackupsresource'))
    filepath = Path(assert_proper_response_with_result(response))
    response = requests.delete(
        api_url_for(
            rotkehlchen_api_server,
            'databasebackupsresource'),
        json={'files': [str(undeletable_file), str(filepath)]},
    )
    assert_error_response(
        response=response,
        contained_in_msg='is not in the user directory',
        status_code=HTTPStatus.CONFLICT,
    )
    assert undeletable_file.exists()
    assert filepath.exists()