diff --git a/swh/deposit/api/common.py b/swh/deposit/api/common.py
--- a/swh/deposit/api/common.py
+++ b/swh/deposit/api/common.py
@@ -54,6 +54,8 @@
)
from ..models import Deposit, DepositClient, DepositCollection, DepositRequest
from ..parsers import parse_xml
+from .checks import check_metadata
+from .converters import convert_status_detail
ACCEPT_PACKAGINGS = ["http://purl.org/net/sword/package/SimpleZip"]
ACCEPT_ARCHIVE_CONTENT_TYPES = ["application/zip", "application/x-tar"]
@@ -653,12 +655,13 @@
"Please ensure your metadata file is correctly formatted.",
)
- if not metadata:
+ metadata_ok, error_details = check_metadata(metadata or {})
+ if not metadata_ok:
+ assert error_details, "Details should be set when a failure occurs"
return make_error_dict(
BAD_REQUEST,
- "Empty body request is not supported",
- "Atom entry deposit is supposed to send for metadata. "
- "If the body is empty, there is no metadata.",
+ "Functional metadata checks failure",
+ convert_status_detail(error_details),
)
external_id = headers["slug"]
diff --git a/swh/deposit/api/deposit_update.py b/swh/deposit/api/deposit_update.py
--- a/swh/deposit/api/deposit_update.py
+++ b/swh/deposit/api/deposit_update.py
@@ -221,15 +221,7 @@
"Please ensure your metadata file is correctly formatted.",
)
- if not metadata:
- return make_error_dict(
- BAD_REQUEST,
- "Empty body request is not supported",
- "Atom entry deposit is supposed to send for metadata. "
- "If the body is empty, there is no metadata.",
- )
-
- metadata_ok, error_details = check_metadata(metadata)
+ metadata_ok, error_details = check_metadata(metadata or {})
if not metadata_ok:
assert error_details, "Details should be set when a failure occurs"
return make_error_dict(
diff --git a/swh/deposit/tests/api/test_deposit_atom.py b/swh/deposit/tests/api/test_deposit_atom.py
--- a/swh/deposit/tests/api/test_deposit_atom.py
+++ b/swh/deposit/tests/api/test_deposit_atom.py
@@ -59,7 +59,7 @@
HTTP_SLUG="external-id",
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert b"Empty body request is not supported" in response.content
+ assert b"Mandatory alternate fields are missing" in response.content
def test_post_deposit_atom_400_badly_formatted_atom(
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
@@ -32,7 +32,7 @@
HTTP_SLUG=deposit.external_id,
HTTP_IN_PROGRESS=True,
)
- assert response.status_code == status.HTTP_201_CREATED
+ assert response.status_code == status.HTTP_201_CREATED, response.content
return deposit
diff --git a/swh/deposit/tests/api/test_deposit_update.py b/swh/deposit/tests/api/test_deposit_update.py
--- a/swh/deposit/tests/api/test_deposit_update.py
+++ b/swh/deposit/tests/api/test_deposit_update.py
@@ -764,7 +764,7 @@
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert b"Empty body request is not supported" in response.content
+ assert b"Mandatory alternate fields are missing" in response.content
def test_put_update_metadata_done_deposit_failure_functional_checks(
diff --git a/swh/deposit/tests/data/atom/codemeta-sample.xml b/swh/deposit/tests/data/atom/codemeta-sample.xml
--- a/swh/deposit/tests/data/atom/codemeta-sample.xml
+++ b/swh/deposit/tests/data/atom/codemeta-sample.xml
@@ -2,6 +2,8 @@
+ The assignment problem
+ Gruenpeter, Morane
hal-01587361
https://hal.inria.fr/hal-01587361
https://hal.inria.fr/hal-01587361/document
diff --git a/swh/deposit/tests/data/atom/entry-data-minimal.xml b/swh/deposit/tests/data/atom/entry-data-minimal.xml
--- a/swh/deposit/tests/data/atom/entry-data-minimal.xml
+++ b/swh/deposit/tests/data/atom/entry-data-minimal.xml
@@ -1,4 +1,5 @@
Awesome Compiler
+ Awesome Coder
diff --git a/swh/deposit/tests/data/atom/entry-data2.xml b/swh/deposit/tests/data/atom/entry-data2.xml
--- a/swh/deposit/tests/data/atom/entry-data2.xml
+++ b/swh/deposit/tests/data/atom/entry-data2.xml
@@ -2,4 +2,5 @@
https://hal-test.archives-ouvertes.fr/some-external-id
some awesome author
+ Some Awesome Software
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 @@
another one
no one
2017-10-07T15:17:08Z
+ Software
diff --git a/swh/deposit/tests/data/atom/error-with-external-identifier.xml b/swh/deposit/tests/data/atom/error-with-external-identifier.xml
--- a/swh/deposit/tests/data/atom/error-with-external-identifier.xml
+++ b/swh/deposit/tests/data/atom/error-with-external-identifier.xml
@@ -2,5 +2,6 @@
Composing a Web of Audio Applications
hal-01243065
+ Someone
hal-01243065