示例#1
0
    def _test_delete():
        """Test relation creation."""
        rec1, rec2 = recrel_choose_endpoints_and_do_request(
            (client, json_headers, "DELETE"),
            (
                first_pid_value,
                first_pid_type,
                second_pid_value,
                second_pid_type,
            ),
            payload,
        )
        recrel_assert_record_relations(rec1, expected={"relations": {}})

        rec_docid_2 = get_test_record(testdata, "documents", "docid-2")
        rec_docid_6 = get_test_record(testdata, "documents", "docid-6")

        recrel_assert_record_relations(
            rec2,
            expected={
                "relations": {
                    "language": [
                        {
                            "pid_value": rec_docid_2["pid"],
                            "pid_type": "docid",
                            "relation_type": "language",
                            "record_metadata": {
                                "title":
                                rec_docid_2["title"],
                                "languages":
                                rec_docid_2["languages"],
                                "document_type":
                                rec_docid_2["document_type"],
                                "publication_year":
                                rec_docid_2["publication_year"],
                            },
                        },
                        {
                            "pid_value": rec_docid_6["pid"],
                            "pid_type": "docid",
                            "relation_type": "language",
                            "record_metadata": {
                                "title":
                                rec_docid_6["title"],
                                "document_type":
                                rec_docid_6["document_type"],
                                "languages":
                                rec_docid_6["languages"],
                                "publication_year":
                                rec_docid_6["publication_year"],
                            },
                        },
                    ]
                }
            },
        )
示例#2
0
def _test_split_sequence(client, json_headers, testdata):
    """Test create split next relations."""
    next_pid_type = "serid"
    previous_pid_value = "serid-2"
    previous_pid_type = "serid"
    relation_type = "sequence"

    payload = {
        "next_pid_type": next_pid_type,
        "previous_pid_value": previous_pid_value,
        "previous_pid_type": previous_pid_type,
        "relation_type": relation_type,
    }

    # serid-1 from previous test
    rec_serid_1 = get_test_record(testdata, "series", "serid-1")
    serid_1 = {
        "pid_value": "serid-1",
        "pid_type": "serid",
        "relation_type": "sequence",
        "relation_order": "continues",
        "record_metadata": {
            "title": rec_serid_1["title"],
            "mode_of_issuance": rec_serid_1["mode_of_issuance"],
        },
    }

    def _test_create_split_sequence(create_using_pid1=True):
        """Test relation creation for split sequence."""
        pid_values = ["serid-3", "serid-4"]
        second_records = []

        for pid_value in pid_values:
            next_pid_value = pid_value
            payload["next_pid_value"] = pid_value
            next_rec, prev_rec = recrel_choose_endpoints_and_do_request(
                (client, json_headers, "POST"),
                (
                    pid_value,
                    next_pid_type,
                    previous_pid_value,
                    previous_pid_type,
                ),
                payload,
                create_using_pid1=create_using_pid1,
            )
            second_records.append(
                {
                    "pid_value": next_pid_value,
                    "pid_type": next_pid_type,
                    "relation_type": "sequence",
                    "relation_order": "is_continued_by",
                    "record_metadata": {
                        "title": next_rec["title"],
                        "mode_of_issuance": next_rec["mode_of_issuance"],
                    },
                }, )

            # serid-2
            recrel_assert_record_relations(
                prev_rec,
                expected={
                    "relations": {
                        "sequence": second_records + [serid_1]
                    }
                },
            )

            # serid-3 and serid-4
            recrel_assert_record_relations(
                next_rec,
                expected={
                    "relations": {
                        "sequence": [{
                            "pid_value": previous_pid_value,
                            "pid_type": previous_pid_type,
                            "relation_type": "sequence",
                            "relation_order": "continues",
                            "record_metadata": {
                                "title": prev_rec["title"],
                                "mode_of_issuance":
                                prev_rec["mode_of_issuance"],
                            },
                        }]
                    }
                },
            )

    _test_create_split_sequence()
示例#3
0
 def test_get_default_location_pid():
     """Asset that the default location is the first created."""
     first = get_test_record(testdata, "locations", "locid-1")
     pid_value, _ = current_app_ils.get_default_location_pid
     assert pid_value == first["pid"]
示例#4
0
    def _test_create():
        """Test relation creation."""
        rec1, rec2 = recrel_choose_endpoints_and_do_request(
            (client, json_headers, "POST"),
            (
                first_pid_value,
                first_pid_type,
                second_pid_value,
                second_pid_type,
            ),
            payload,
        )

        rec_docid_1 = get_test_record(testdata, "documents", "docid-1")
        rec_docid_6 = get_test_record(testdata, "documents", "docid-6")

        recrel_assert_record_relations(
            rec1,
            expected={
                "relations_extra_metadata": {
                    "other": [{
                        "pid_value": second_pid_value,
                        "pid_type": second_pid_type,
                        "note": "exercise",
                    }]
                },
                "relations": {
                    "language": [
                        {
                            "pid_value": rec_docid_1["pid"],
                            "pid_type": "docid",
                            "relation_type": "language",
                            "record_metadata": {
                                "title":
                                rec_docid_1["title"],
                                "edition":
                                rec_docid_1["edition"],
                                "languages":
                                rec_docid_1["languages"],
                                "document_type":
                                rec_docid_1["document_type"],
                                "publication_year":
                                rec_docid_1["publication_year"],
                            },
                        },
                        {
                            "pid_value": rec_docid_6["pid"],
                            "pid_type": "docid",
                            "relation_type": "language",
                            "record_metadata": {
                                "title":
                                rec_docid_6["title"],
                                "document_type":
                                rec_docid_6["document_type"],
                                "languages":
                                rec_docid_6["languages"],
                                "publication_year":
                                rec_docid_6["publication_year"],
                            },
                        },
                    ],
                    "other": [{
                        "pid_value": second_pid_value,
                        "pid_type": second_pid_type,
                        "note": "exercise",
                        "relation_type": "other",
                        "record_metadata": {
                            "title": rec2["title"],
                            "edition": rec2["edition"],
                            "document_type": rec2["document_type"],
                            "publication_year": rec2["publication_year"],
                        },
                    }],
                },
            },
        )
        recrel_assert_record_relations(
            rec2,
            expected={
                "relations": {
                    "edition": [{
                        "pid_value": rec_docid_1["pid"],
                        "pid_type": "docid",
                        "relation_type": "edition",
                        "record_metadata": {
                            "title": rec_docid_1["title"],
                            "edition": rec_docid_1["edition"],
                            "languages": rec_docid_1["languages"],
                            "document_type": rec_docid_1["document_type"],
                            "publication_year":
                            rec_docid_1["publication_year"],
                        },
                    }],
                    "other": [{
                        "pid_value": first_pid_value,
                        "pid_type": first_pid_type,
                        "note": "exercise",
                        "relation_type": "other",
                        "record_metadata": {
                            "title": rec1["title"],
                            "languages": rec1["languages"],
                            "document_type": rec1["document_type"],
                            "publication_year": rec1["publication_year"],
                        },
                    }],
                }
            },
        )