Page MenuHomeSoftware Heritage

D6903.id25035.diff
No OneTemporary

D6903.id25035.diff

diff --git a/swh/deposit/api/private/deposit_read.py b/swh/deposit/api/private/deposit_read.py
--- a/swh/deposit/api/private/deposit_read.py
+++ b/swh/deposit/api/private/deposit_read.py
@@ -170,6 +170,12 @@
else:
parents = []
+ release_notes = metadata.get("codemeta:releaseNotes")
+ if isinstance(release_notes, list):
+ release_notes = "\n\n".join(release_notes)
+ if not release_notes:
+ release_notes = None
+
return {
"origin": {"type": "deposit", "url": deposit.origin_url},
"provider": {
@@ -190,6 +196,7 @@
"committer": SWH_PERSON,
"committer_date": commit_date,
"revision_parents": parents,
+ "release_notes": release_notes,
},
}
diff --git a/swh/deposit/tests/api/test_deposit_private_read_metadata.py b/swh/deposit/tests/api/test_deposit_private_read_metadata.py
--- a/swh/deposit/tests/api/test_deposit_private_read_metadata.py
+++ b/swh/deposit/tests/api/test_deposit_private_read_metadata.py
@@ -96,6 +96,7 @@
"id": deposit.id,
"collection": "test",
"revision_parents": [],
+ "release_notes": "This is the release of October 7th, 2017.",
},
}
@@ -169,6 +170,7 @@
"id": deposit.id,
"collection": "test",
"revision_parents": [rev_id],
+ "release_notes": "This is the release of October 7th, 2017.",
},
}
@@ -244,6 +246,7 @@
"id": deposit.id,
"collection": deposit_collection.name,
"revision_parents": [],
+ "release_notes": "This is the release of October 7th, 2017.",
},
}
@@ -303,6 +306,7 @@
"id": deposit.id,
"collection": deposit_collection.name,
"revision_parents": [],
+ "release_notes": None,
},
}
@@ -375,6 +379,7 @@
"id": deposit.id,
"collection": deposit_collection.name,
"revision_parents": [],
+ "release_notes": None,
},
}
@@ -396,3 +401,71 @@
assert response.status_code == status.HTTP_404_NOT_FOUND
msg = "Deposit %s does not exist" % unknown_id
assert msg in response.content.decode("utf-8")
+
+
+def test_read_metadata_multiple_release_notes(
+ authenticated_client, deposit_collection, partial_deposit, atom_dataset
+):
+ """Private metadata read api to existing deposit should return metadata
+
+ """
+ deposit = partial_deposit
+ deposit.external_id = "some-external-id"
+ deposit.origin_url = f"https://hal-test.archives-ouvertes.fr/{deposit.external_id}"
+ deposit.save()
+
+ metadata_xml_atoms = [
+ atom_dataset[atom_key] for atom_key in ["entry-data-multiple-release-notes"]
+ ]
+ metadata_xml_raws = [parse_xml(xml) for xml in metadata_xml_atoms]
+ for atom_xml in metadata_xml_atoms:
+ deposit = update_deposit_with_metadata(
+ authenticated_client, deposit_collection, deposit, atom_xml,
+ )
+
+ for url in private_get_raw_url_endpoints(deposit_collection, deposit):
+ response = authenticated_client.get(url)
+ assert response.status_code == status.HTTP_200_OK
+ assert response["content-type"] == "application/json"
+ actual_data = response.json()
+ assert actual_data == {
+ "origin": {
+ "type": "deposit",
+ "url": "https://hal-test.archives-ouvertes.fr/some-external-id",
+ },
+ "metadata_raw": metadata_xml_atoms,
+ "metadata_dict": utils.merge(*metadata_xml_raws),
+ "provider": {
+ "metadata": {},
+ "provider_name": "",
+ "provider_type": "deposit_client",
+ "provider_url": "https://hal-test.archives-ouvertes.fr/",
+ },
+ "tool": {
+ "configuration": {"sword_version": "2"},
+ "name": "swh-deposit",
+ "version": __version__,
+ },
+ "deposit": {
+ "author": SWH_PERSON,
+ "committer": SWH_PERSON,
+ "committer_date": {
+ "negative_utc": False,
+ "offset": 0,
+ "timestamp": {"microseconds": 0, "seconds": 1507389428},
+ },
+ "author_date": {
+ "negative_utc": False,
+ "offset": 0,
+ "timestamp": {"microseconds": 0, "seconds": 1507389428},
+ },
+ "client": "test",
+ "id": deposit.id,
+ "collection": "test",
+ "revision_parents": [],
+ "release_notes": (
+ "This is the release of October 7th, 2017.\n\n"
+ "It fixes some bugs."
+ ),
+ },
+ }
diff --git a/swh/deposit/tests/data/atom/entry-data3.xml b/swh/deposit/tests/data/atom/entry-data-multiple-release-notes.xml
copy from swh/deposit/tests/data/atom/entry-data3.xml
copy to swh/deposit/tests/data/atom/entry-data-multiple-release-notes.xml
--- a/swh/deposit/tests/data/atom/entry-data3.xml
+++ b/swh/deposit/tests/data/atom/entry-data-multiple-release-notes.xml
@@ -3,4 +3,6 @@
<author>another one</author>
<author>no one</author>
<codemeta:dateCreated>2017-10-07T15:17:08Z</codemeta:dateCreated>
+ <codemeta:releaseNotes>This is the release of October 7th, 2017.</codemeta:releaseNotes>
+ <codemeta:releaseNotes>It fixes some bugs.</codemeta:releaseNotes>
</entry>
diff --git a/swh/deposit/tests/data/atom/entry-data3.xml b/swh/deposit/tests/data/atom/entry-data3.xml
--- a/swh/deposit/tests/data/atom/entry-data3.xml
+++ b/swh/deposit/tests/data/atom/entry-data3.xml
@@ -3,4 +3,5 @@
<author>another one</author>
<author>no one</author>
<codemeta:dateCreated>2017-10-07T15:17:08Z</codemeta:dateCreated>
+ <codemeta:releaseNotes>This is the release of October 7th, 2017.</codemeta:releaseNotes>
</entry>

File Metadata

Mime Type
text/plain
Expires
Nov 4 2024, 8:44 PM (9 w, 2 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3228628

Event Timeline