Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_private_read_metadata.py
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | ): | ||||
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._headers["content-type"][1] == "application/json" | ||||
data = response.json() | data = response.json() | ||||
expected_meta = { | expected_meta = { | ||||
"branch_name": "master", | |||||
"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", | ||||
}, | }, | ||||
"origin_metadata": { | "origin_metadata": { | ||||
"metadata": { | "metadata": { | ||||
"@xmlns": ["http://www.w3.org/2005/Atom"], | "@xmlns": ["http://www.w3.org/2005/Atom"], | ||||
"author": ["some awesome author", "another one", "no one"], | "author": ["some awesome author", "another one", "no one"], | ||||
"codemeta:dateCreated": "2017-10-07T15:17:08Z", | "codemeta:dateCreated": "2017-10-07T15:17:08Z", | ||||
"external_identifier": "some-external-id", | "external_identifier": "some-external-id", | ||||
"url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa | "url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa | ||||
}, | }, | ||||
"provider": { | "provider": { | ||||
"metadata": {}, | "metadata": {}, | ||||
"provider_name": "", | "provider_name": "", | ||||
"provider_type": "deposit_client", | "provider_type": "deposit_client", | ||||
"provider_url": "https://hal-test.archives-ouvertes.fr/", | "provider_url": "https://hal-test.archives-ouvertes.fr/", | ||||
}, | }, | ||||
"tool": { | "tool": { | ||||
"configuration": {"sword_version": "2"}, | "configuration": {"sword_version": "2"}, | ||||
"name": "swh-deposit", | "name": "swh-deposit", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
}, | }, | ||||
}, | }, | ||||
"revision": { | "deposit": { | ||||
"author": SWH_PERSON, | "author": SWH_PERSON, | ||||
"committer": SWH_PERSON, | "committer": SWH_PERSON, | ||||
"committer_date": { | "committer_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 0, | "offset": 0, | ||||
"timestamp": {"microseconds": 0, "seconds": 1507389428}, | "timestamp": {"microseconds": 0, "seconds": 1507389428}, | ||||
}, | }, | ||||
"date": { | "author_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 0, | "offset": 0, | ||||
"timestamp": {"microseconds": 0, "seconds": 1507389428}, | "timestamp": {"microseconds": 0, "seconds": 1507389428}, | ||||
}, | }, | ||||
"message": "test: Deposit %s in collection test" % deposit.id, | "client": "test", | ||||
"metadata": { | "id": deposit.id, | ||||
"@xmlns": ["http://www.w3.org/2005/Atom"], | "collection": "test", | ||||
"author": ["some awesome author", "another one", "no one"], | "revision_parents": [], | ||||
"codemeta:dateCreated": "2017-10-07T15:17:08Z", | |||||
"external_identifier": "some-external-id", | |||||
"url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa | |||||
}, | |||||
"synthetic": True, | |||||
"type": "tar", | |||||
}, | }, | ||||
} | } | ||||
assert data == expected_meta | assert data == expected_meta | ||||
def test_read_metadata_revision_with_parent( | def test_read_metadata_revision_with_parent( | ||||
authenticated_client, deposit_collection, partial_deposit, atom_dataset | authenticated_client, deposit_collection, partial_deposit, atom_dataset | ||||
Show All 19 Lines | ): | ||||
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._headers["content-type"][1] == "application/json" | ||||
data = response.json() | data = response.json() | ||||
expected_meta = { | expected_meta = { | ||||
"branch_name": "master", | |||||
"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", | ||||
}, | }, | ||||
"origin_metadata": { | "origin_metadata": { | ||||
"metadata": { | "metadata": { | ||||
"@xmlns": ["http://www.w3.org/2005/Atom"], | "@xmlns": ["http://www.w3.org/2005/Atom"], | ||||
"author": ["some awesome author", "another one", "no one"], | "author": ["some awesome author", "another one", "no one"], | ||||
"codemeta:dateCreated": "2017-10-07T15:17:08Z", | "codemeta:dateCreated": "2017-10-07T15:17:08Z", | ||||
"external_identifier": "some-external-id", | "external_identifier": "some-external-id", | ||||
"url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa | "url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa | ||||
}, | }, | ||||
"provider": { | "provider": { | ||||
"metadata": {}, | "metadata": {}, | ||||
"provider_name": "", | "provider_name": "", | ||||
"provider_type": "deposit_client", | "provider_type": "deposit_client", | ||||
"provider_url": "https://hal-test.archives-ouvertes.fr/", | "provider_url": "https://hal-test.archives-ouvertes.fr/", | ||||
}, | }, | ||||
"tool": { | "tool": { | ||||
"configuration": {"sword_version": "2"}, | "configuration": {"sword_version": "2"}, | ||||
"name": "swh-deposit", | "name": "swh-deposit", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
}, | }, | ||||
}, | }, | ||||
"revision": { | "deposit": { | ||||
"author": SWH_PERSON, | "author": SWH_PERSON, | ||||
"committer": SWH_PERSON, | "committer": SWH_PERSON, | ||||
"committer_date": { | "committer_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 0, | "offset": 0, | ||||
"timestamp": {"microseconds": 0, "seconds": 1507389428}, | "timestamp": {"microseconds": 0, "seconds": 1507389428}, | ||||
}, | }, | ||||
"date": { | "author_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 0, | "offset": 0, | ||||
"timestamp": {"microseconds": 0, "seconds": 1507389428}, | "timestamp": {"microseconds": 0, "seconds": 1507389428}, | ||||
}, | }, | ||||
"message": "test: Deposit %s in collection test" % deposit.id, | "client": "test", | ||||
"metadata": { | "id": deposit.id, | ||||
"@xmlns": ["http://www.w3.org/2005/Atom"], | "collection": "test", | ||||
"author": ["some awesome author", "another one", "no one"], | "revision_parents": [rev_id], | ||||
"codemeta:dateCreated": "2017-10-07T15:17:08Z", | |||||
"external_identifier": "some-external-id", | |||||
"url": "https://hal-test.archives-ouvertes.fr/some-external-id", # noqa | |||||
}, | |||||
"synthetic": True, | |||||
"type": "tar", | |||||
"parents": [rev_id], | |||||
}, | }, | ||||
} | } | ||||
assert data == expected_meta | assert data == expected_meta | ||||
def test_read_metadata_3( | def test_read_metadata_3( | ||||
authenticated_client, deposit_collection, partial_deposit, atom_dataset | authenticated_client, deposit_collection, partial_deposit, atom_dataset | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
"codemeta:url": "https://hal-test.archives-ouvertes.fr/hal-01243065", # noqa | "codemeta:url": "https://hal-test.archives-ouvertes.fr/hal-01243065", # noqa | ||||
"codemeta:version": "1", | "codemeta:version": "1", | ||||
"external_identifier": ["some-external-id", "hal-01243065"], | "external_identifier": ["some-external-id", "hal-01243065"], | ||||
"id": "hal-01243065", | "id": "hal-01243065", | ||||
"title": "Composing a Web of Audio " "Applications", | "title": "Composing a Web of Audio " "Applications", | ||||
"url": "https://hal-test.archives-ouvertes.fr/some-external-id", | "url": "https://hal-test.archives-ouvertes.fr/some-external-id", | ||||
} | } | ||||
expected_meta = { | expected_meta = { | ||||
"branch_name": "master", | |||||
"origin": { | "origin": { | ||||
"type": "deposit", | "type": "deposit", | ||||
"url": "https://hal-test.archives-ouvertes.fr/hal-01243065", | "url": "https://hal-test.archives-ouvertes.fr/hal-01243065", | ||||
}, | }, | ||||
"origin_metadata": { | "origin_metadata": { | ||||
"metadata": metadata, | "metadata": metadata, | ||||
"provider": { | "provider": { | ||||
"metadata": {}, | "metadata": {}, | ||||
"provider_name": "", | "provider_name": "", | ||||
"provider_type": "deposit_client", | "provider_type": "deposit_client", | ||||
"provider_url": "https://hal-test.archives-ouvertes.fr/", | "provider_url": "https://hal-test.archives-ouvertes.fr/", | ||||
}, | }, | ||||
"tool": { | "tool": { | ||||
"configuration": {"sword_version": "2"}, | "configuration": {"sword_version": "2"}, | ||||
"name": "swh-deposit", | "name": "swh-deposit", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
}, | }, | ||||
}, | }, | ||||
"revision": { | "deposit": { | ||||
"author": SWH_PERSON, | "author": SWH_PERSON, | ||||
"committer": SWH_PERSON, | "committer": SWH_PERSON, | ||||
"committer_date": { | "committer_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 120, | "offset": 120, | ||||
"timestamp": {"microseconds": 0, "seconds": 1493820527}, | "timestamp": {"microseconds": 0, "seconds": 1493820527}, | ||||
}, | }, | ||||
"date": { | "author_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 0, | "offset": 0, | ||||
"timestamp": {"microseconds": 0, "seconds": 1507389428}, | "timestamp": {"microseconds": 0, "seconds": 1507389428}, | ||||
}, | }, | ||||
"message": "%s: Deposit %s in collection %s" | "client": deposit_collection.name, | ||||
% (deposit_collection.name, deposit.id, deposit_collection.name), | "id": deposit.id, | ||||
"metadata": metadata, | "collection": deposit_collection.name, | ||||
"synthetic": True, | "revision_parents": [], | ||||
"type": "tar", | |||||
}, | }, | ||||
} | } | ||||
assert data == expected_meta | assert data == expected_meta | ||||
def test_read_metadata_4( | def test_read_metadata_4( | ||||
authenticated_client, deposit_collection, atom_dataset, partial_deposit | authenticated_client, deposit_collection, atom_dataset, partial_deposit | ||||
): | ): | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
}, | }, | ||||
"tool": { | "tool": { | ||||
"configuration": {"sword_version": "2"}, | "configuration": {"sword_version": "2"}, | ||||
"name": "swh-deposit", | "name": "swh-deposit", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
}, | }, | ||||
} | } | ||||
expected_revision = { | expected_deposit_info = { | ||||
"author": { | "author": SWH_PERSON, | ||||
"email": "robot@softwareheritage.org", | "committer": SWH_PERSON, | ||||
"fullname": "Software Heritage", | |||||
"name": "Software Heritage", | |||||
}, | |||||
"committer": { | |||||
"email": "robot@softwareheritage.org", | |||||
"fullname": "Software Heritage", | |||||
"name": "Software Heritage", | |||||
}, | |||||
"committer_date": { | "committer_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 0, | "offset": 0, | ||||
"timestamp": {"microseconds": 0, "seconds": 1459900800}, | "timestamp": {"microseconds": 0, "seconds": 1459900800}, | ||||
}, | }, | ||||
"date": { | "author_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 0, | "offset": 0, | ||||
"timestamp": {"microseconds": 0, "seconds": 1459900800}, | "timestamp": {"microseconds": 0, "seconds": 1459900800}, | ||||
}, | }, | ||||
"message": "%s: Deposit %s in collection %s" | "client": deposit_collection.name, | ||||
% (deposit_collection.name, deposit.id, deposit_collection.name), | "id": deposit.id, | ||||
"metadata": metadata, | "collection": deposit_collection.name, | ||||
"synthetic": True, | "revision_parents": [], | ||||
"type": "tar", | |||||
} | } | ||||
expected_meta = { | expected_meta = { | ||||
"branch_name": "master", | |||||
"origin": expected_origin, | "origin": expected_origin, | ||||
"origin_metadata": expected_origin_metadata, | "origin_metadata": expected_origin_metadata, | ||||
"revision": expected_revision, | "deposit": expected_deposit_info, | ||||
} | } | ||||
assert data == expected_meta | assert data == expected_meta | ||||
def test_read_metadata_5( | def test_read_metadata_5( | ||||
authenticated_client, deposit_collection, partial_deposit, atom_dataset | authenticated_client, deposit_collection, partial_deposit, atom_dataset | ||||
): | ): | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | for url in private_get_raw_url_endpoints(deposit_collection, deposit): | ||||
}, | }, | ||||
"tool": { | "tool": { | ||||
"configuration": {"sword_version": "2"}, | "configuration": {"sword_version": "2"}, | ||||
"name": "swh-deposit", | "name": "swh-deposit", | ||||
"version": "0.0.1", | "version": "0.0.1", | ||||
}, | }, | ||||
} | } | ||||
expected_revision = { | expected_deposit_info = { | ||||
"author": { | "author": SWH_PERSON, | ||||
"email": "robot@softwareheritage.org", | "committer": SWH_PERSON, | ||||
"fullname": "Software Heritage", | |||||
"name": "Software Heritage", | |||||
}, | |||||
"committer": { | |||||
"email": "robot@softwareheritage.org", | |||||
"fullname": "Software Heritage", | |||||
"name": "Software Heritage", | |||||
}, | |||||
"committer_date": { | "committer_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 120, | "offset": 120, | ||||
"timestamp": {"microseconds": 0, "seconds": 1493820527}, | "timestamp": {"microseconds": 0, "seconds": 1493820527}, | ||||
}, | }, | ||||
"date": { | "author_date": { | ||||
"negative_utc": False, | "negative_utc": False, | ||||
"offset": 120, | "offset": 120, | ||||
"timestamp": {"microseconds": 0, "seconds": 1428332927}, | "timestamp": {"microseconds": 0, "seconds": 1428332927}, | ||||
}, | }, | ||||
"message": "%s: Deposit %s in collection %s" | "client": deposit_collection.name, | ||||
% (deposit_collection.name, deposit.id, deposit_collection.name), | "id": deposit.id, | ||||
"metadata": metadata, | "collection": deposit_collection.name, | ||||
"synthetic": True, | "revision_parents": [], | ||||
"type": "tar", | |||||
} | } | ||||
expected_meta = { | expected_meta = { | ||||
"branch_name": "master", | |||||
moranegg: who is in charge of the branch? | |||||
Done Inline Actionsthe loader (see previous comment for more details). ardumont: the loader (see previous comment for more details). | |||||
"origin": expected_origin, | "origin": expected_origin, | ||||
"origin_metadata": expected_origin_metadata, | "origin_metadata": expected_origin_metadata, | ||||
"revision": expected_revision, | "deposit": expected_deposit_info, | ||||
} | } | ||||
assert data == expected_meta | assert data == expected_meta | ||||
def test_access_to_nonexisting_deposit_returns_404_response( | def test_access_to_nonexisting_deposit_returns_404_response( | ||||
authenticated_client, deposit_collection, | authenticated_client, deposit_collection, | ||||
): | ): | ||||
Show All 14 Lines |
who is in charge of the branch?