def test_relation_pids_given_as_urls(
admin_client,
dataset_a_json,
entity_json,
data_catalog,
datacatalog_harvested_json,
reference_data,
):
dataset_with_urn = admin_client.post(
"/v3/datasets", dataset_a_json, content_type="application/json"
)
assert dataset_with_urn.status_code == 201
dataset_a_json["data_catalog"] = datacatalog_harvested_json["id"]
dataset_a_json["persistent_identifier"] = "doi:test_doi"
dataset_with_doi = admin_client.post(
"/v3/datasets", dataset_a_json, content_type="application/json"
)
other_identifier = {
"notation": "http://urn.fi/" + dataset_with_urn.data["persistent_identifier"]
}
entity_json["entity_identifier"] = "https://doi.org/" + "test_doi"
relation = {
"entity": entity_json,
"relation_type": {"url": "http://purl.org/dc/terms/relation"},
}
dataset_a_json["data_catalog"] = "urn:nbn:fi:att:data-catalog-ida"
del dataset_a_json["persistent_identifier"]
dataset_a_json["relation"] = [relation]
dataset_a_json["other_identifiers"] = [other_identifier]
res1 = admin_client.post("/v3/datasets", dataset_a_json, content_type="application/json")
assert res1.status_code == 201
assert str(res1.data["other_identifiers"][0]["metax_ids"][0]) == dataset_with_urn.data["id"]
assert str(res1.data["relation"][0]["metax_ids"][0]) == dataset_with_doi.data["id"]