Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_private_read_metadata.py
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | ): | ||||
for atom_xml in metadata_xml_atoms: | for atom_xml in metadata_xml_atoms: | ||||
deposit = update_deposit_with_metadata( | deposit = update_deposit_with_metadata( | ||||
authenticated_client, deposit_collection, deposit, atom_xml, | authenticated_client, deposit_collection, deposit, atom_xml, | ||||
) | ) | ||||
for url in private_get_raw_url_endpoints(deposit_collection, deposit): | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
response = authenticated_client.get(url) | response = authenticated_client.get(url) | ||||
assert response.status_code == status.HTTP_200_OK | assert response.status_code == status.HTTP_200_OK | ||||
assert response._headers["content-type"][1] == "application/json" | assert response["content-type"] == "application/json" | ||||
actual_data = response.json() | actual_data = response.json() | ||||
assert actual_data == { | assert actual_data == { | ||||
"origin": { | "origin": { | ||||
"type": "deposit", | "type": "deposit", | ||||
"url": "https://hal-test.archives-ouvertes.fr/some-external-id", | "url": "https://hal-test.archives-ouvertes.fr/some-external-id", | ||||
}, | }, | ||||
"metadata_raw": metadata_xml_atoms, | "metadata_raw": metadata_xml_atoms, | ||||
"metadata_dict": utils.merge(*metadata_xml_raws), | "metadata_dict": utils.merge(*metadata_xml_raws), | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | ): | ||||
fake_parent.save() | fake_parent.save() | ||||
deposit.parent = fake_parent | deposit.parent = fake_parent | ||||
deposit.save() | deposit.save() | ||||
for url in private_get_raw_url_endpoints(deposit_collection, deposit): | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
response = authenticated_client.get(url) | response = authenticated_client.get(url) | ||||
assert response.status_code == status.HTTP_200_OK | assert response.status_code == status.HTTP_200_OK | ||||
assert response._headers["content-type"][1] == "application/json" | assert response["content-type"] == "application/json" | ||||
actual_data = response.json() | actual_data = response.json() | ||||
assert actual_data == { | assert actual_data == { | ||||
"origin": { | "origin": { | ||||
"type": "deposit", | "type": "deposit", | ||||
"url": "https://hal-test.archives-ouvertes.fr/some-external-id", | "url": "https://hal-test.archives-ouvertes.fr/some-external-id", | ||||
}, | }, | ||||
"metadata_raw": metadata_xml_atoms, | "metadata_raw": metadata_xml_atoms, | ||||
"metadata_dict": utils.merge(*metadata_xml_raws), | "metadata_dict": utils.merge(*metadata_xml_raws), | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | for atom_xml in metadata_xml_atoms: | ||||
update_deposit_with_metadata( | update_deposit_with_metadata( | ||||
authenticated_client, deposit_collection, deposit, atom_xml, | authenticated_client, deposit_collection, deposit, atom_xml, | ||||
) | ) | ||||
for url in private_get_raw_url_endpoints(deposit_collection, deposit): | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
response = authenticated_client.get(url) | response = authenticated_client.get(url) | ||||
assert response.status_code == status.HTTP_200_OK | assert response.status_code == status.HTTP_200_OK | ||||
assert response._headers["content-type"][1] == "application/json" | assert response["content-type"] == "application/json" | ||||
actual_data = response.json() | actual_data = response.json() | ||||
assert actual_data == { | assert actual_data == { | ||||
"origin": { | "origin": { | ||||
"type": "deposit", | "type": "deposit", | ||||
"url": "https://hal-test.archives-ouvertes.fr/hal-01243065", | "url": "https://hal-test.archives-ouvertes.fr/hal-01243065", | ||||
}, | }, | ||||
"metadata_raw": metadata_xml_atoms, | "metadata_raw": metadata_xml_atoms, | ||||
"metadata_dict": utils.merge(*metadata_xml_raws), | "metadata_dict": utils.merge(*metadata_xml_raws), | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | ): | ||||
# will use the deposit completed date as fallback date | # will use the deposit completed date as fallback date | ||||
deposit.complete_date = "2016-04-06" | deposit.complete_date = "2016-04-06" | ||||
deposit.save() | deposit.save() | ||||
for url in private_get_raw_url_endpoints(deposit_collection, deposit): | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
response = authenticated_client.get(url) | response = authenticated_client.get(url) | ||||
assert response.status_code == status.HTTP_200_OK | assert response.status_code == status.HTTP_200_OK | ||||
assert response._headers["content-type"][1] == "application/json" | assert response["content-type"] == "application/json" | ||||
actual_data = response.json() | actual_data = response.json() | ||||
assert actual_data == { | assert actual_data == { | ||||
"origin": {"type": "deposit", "url": None,}, | "origin": {"type": "deposit", "url": None,}, | ||||
"metadata_raw": [codemeta_entry_data], | "metadata_raw": [codemeta_entry_data], | ||||
"metadata_dict": parse_xml(codemeta_entry_data), | "metadata_dict": parse_xml(codemeta_entry_data), | ||||
"provider": { | "provider": { | ||||
"metadata": {}, | "metadata": {}, | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | """ | ||||
deposit = update_deposit_with_metadata( | deposit = update_deposit_with_metadata( | ||||
authenticated_client, deposit_collection, deposit, codemeta_entry_data | authenticated_client, deposit_collection, deposit, codemeta_entry_data | ||||
) | ) | ||||
for url in private_get_raw_url_endpoints(deposit_collection, deposit): | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
response = authenticated_client.get(url) | response = authenticated_client.get(url) | ||||
assert response.status_code == status.HTTP_200_OK | assert response.status_code == status.HTTP_200_OK | ||||
assert response._headers["content-type"][1] == "application/json" | assert response["content-type"] == "application/json" | ||||
actual_data = response.json() | actual_data = response.json() | ||||
assert actual_data == { | assert actual_data == { | ||||
"origin": { | "origin": { | ||||
"type": "deposit", | "type": "deposit", | ||||
"url": "https://hal-test.archives-ouvertes.fr/hal-01243065", | "url": "https://hal-test.archives-ouvertes.fr/hal-01243065", | ||||
}, | }, | ||||
"metadata_raw": [codemeta_entry_data], | "metadata_raw": [codemeta_entry_data], | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |