コード例 #1
0
def test_post_partial_internal_location(client, json_headers, testdata, users):
    """Test POST of internal_location without all required data."""
    user_login(client, "admin", users)
    del NEW_INTERNAL_LOCATION["location_pid"]
    url = url_for("invenio_records_rest.ilocid_list")
    validate_response(client, "post", url, json_headers, NEW_INTERNAL_LOCATION,
                      400)
def test_get_document_request_endpoint(
    client,
    json_headers,
    testdata,
    users,
    user,
    res_id,
    expected_resp_code,
):
    """Test GET permissions."""
    user_login(client, user, users)
    url = url_for("invenio_records_rest.dreqid_item", pid_value=res_id)
    validate_response(
        client, "get", url, json_headers, None, expected_resp_code)
def test_document_request_remove_provider(
    client,
    json_headers,
    testdata,
    users,
    user,
    res_id,
    expected_resp_code,
):
    """Test remove provider from Document Request permissions."""
    user_login(client, user, users)
    url = url_for("ils_document_request.dreqid_provider", pid_value=res_id)
    validate_response(
        client, "delete", url, json_headers, None, expected_resp_code)
def test_document_request_remove_document(
    client,
    json_headers,
    testdata,
    users,
    user,
    res_id,
    expected_resp_code,
):
    """Test remove document from Document Request permissions."""
    user_login(client, user, users)
    url = url_for("ils_document_request.dreqid_document", pid_value=res_id)
    data = {"document_pid": "docid-1"}
    validate_response(
        client, "delete", url, json_headers, data, expected_resp_code)
def test_document_request_reject(
    client,
    json_headers,
    testdata,
    users,
    user,
    res_id,
    expected_resp_code,
):
    """Test Document Request permissions to reject request."""
    user_login(client, user, users)
    url = url_for("ils_document_request.dreqid_reject", pid_value=res_id)
    data = {"reject_reason": "USER_CANCEL"}
    validate_response(
        client, "post", url, json_headers, data, expected_resp_code)
def test_document_request_accept(
    client,
    json_headers,
    testdata,
    users,
    user,
    res_id,
    expected_resp_code,
):
    """Test Document Request permissions to accept request."""
    user_login(client, user, users)
    url = url_for("ils_document_request.dreqid_accept", pid_value=res_id)
    data = {"state": "ACCEPTED"}
    validate_response(
        client, "post", url, json_headers, data, expected_resp_code)
def test_document_request_add_document(
    client,
    json_headers,
    testdata,
    users,
    user_id,
    res_id,
    expected_resp_code,
):
    """Test add document to Document Request permissions."""
    user_login(user_id, client, users)
    url = url_for("ils_document_request.dreqid_document", pid_value=res_id)
    data = {"document_pid": "docid-1"}
    validate_response(client, "post", url, json_headers, data,
                      expected_resp_code)
コード例 #8
0
def test_get_item_endpoint(
    client,
    json_headers,
    testdata,
    users,
    with_access,
    user_id,
    res_id,
    expected_resp_code,
):
    """Test GET permissions."""
    user_login(user_id, client, users)
    url = url_for("invenio_records_rest.pitmid_item", pid_value=res_id)
    validate_response(client, "get", url, json_headers, None,
                      expected_resp_code)
コード例 #9
0
def test_post_internal_location(client, json_headers, testdata, users):
    """Test POST of internal_location."""
    user_login(client, "admin", users)
    url = url_for("invenio_records_rest.ilocid_list")
    res = validate_response(client, "post", url, json_headers,
                            NEW_INTERNAL_LOCATION, 201)
    data = json.loads(res.data.decode("utf-8"))["metadata"]
    assert "name" in data["location"]
コード例 #10
0
def test_post_item(client, json_headers, testdata, users, item_record):
    """Test POST of an item."""
    user_login("admin", client, users)
    url = url_for("invenio_records_rest.pitmid_list")
    del item_record["pid"]
    res = validate_response(
        client, "post", url, json_headers, item_record, 201)
    data = json.loads(res.data.decode("utf-8"))["metadata"]
    assert "name" in data["internal_location"]
def test_document_request_add_provider(
    client,
    json_headers,
    testdata,
    users,
    user,
    res_id,
    expected_resp_code,
):
    """Test add provider to Document Request permissions."""
    user_login(client, user, users)
    url = url_for("ils_document_request.dreqid_provider", pid_value=res_id)
    data = {
        "physical_item_provider": {
            "pid": "acquisition-order-pid",
            "pid_type": "acquisition"
        }
    }
    validate_response(
        client, "post", url, json_headers, data, expected_resp_code)
コード例 #12
0
def test_delete_item_endpoint(
    client,
    json_headers,
    testdata,
    users,
    user_id,
    res_id,
    expected_resp_code,
    item_record,
):
    """Test DELETE permissions of an item."""
    user_login(user_id, client, users)
    url = url_for("invenio_records_rest.pitmid_item", pid_value=res_id)
    validate_response(
        client,
        "delete",
        url,
        json_headers,
        data=item_record,
        expected_resp_code=expected_resp_code,
    )
コード例 #13
0
def test_put_item_endpoint(
    client,
    json_headers,
    testdata,
    users,
    user_id,
    res_id,
    expected_resp_code,
    item_record,
):
    """Test PUT permissions of an item."""
    url = url_for("invenio_records_rest.pitmid_item", pid_value=res_id)
    user_login(user_id, client, users)
    ITEM = copy.deepcopy(item_record)
    res = validate_response(client, "put", url, json_headers, ITEM,
                            expected_resp_code)
    validate_data("pid", res_id, res)
コード例 #14
0
def test_post_item_endpoint(
    client,
    json_headers,
    testdata,
    users,
    user_id,
    expected_resp_code,
    item_record,
):
    """Test POST permissions of an item."""
    user_login(user_id, client, users)
    url = url_for("invenio_records_rest.pitmid_list")
    ITEM = copy.deepcopy(item_record)
    if "pid" in ITEM:
        del ITEM["pid"]
    res = validate_response(client, "post", url, json_headers, ITEM,
                            expected_resp_code)
    validate_data("barcode", ITEM["barcode"], res)
コード例 #15
0
def test_item_circulation(
    client,
    json_headers,
    testdata,
    users,
    user_id,
    res_id,
    expected_resp_code,
    filtered,
):
    """Test item circulation filtering."""
    user_login(user_id, client, users)
    url = url_for("invenio_records_rest.pitmid_item", pid_value=res_id)
    res = validate_response(client, "get", url, json_headers, None,
                            expected_resp_code)
    circulation = res.json["metadata"]["circulation"]
    filter_keys = ["loan_pid", "patron_pid"]
    if filtered:
        for key in filter_keys:
            assert key not in circulation
    else:
        for key in filter_keys:
            assert key in circulation