Page MenuHomeSoftware Heritage

D4052.diff
No OneTemporary

D4052.diff

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
@@ -160,10 +160,12 @@
request, headers, collection_name, deposit_id=deposit_id
)
return (status.HTTP_201_CREATED, EM_IRI, data)
- # check for final empty post
- # source: http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html
- # #continueddeposit_complete
- if headers["content-length"] == 0 and headers["in-progress"] is False:
+
+ content_length = headers["content-length"] or 0
+ if content_length == 0 and headers["in-progress"] is False:
+ # check for final empty post
+ # source: http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html
+ # #continueddeposit_complete
data = self._empty_post(request, headers, collection_name, deposit_id)
return (status.HTTP_200_OK, EDIT_SE_IRI, data)
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
@@ -9,7 +9,12 @@
from django.urls import reverse
from rest_framework import status
-from swh.deposit.config import EDIT_SE_IRI, EM_IRI
+from swh.deposit.config import (
+ DEPOSIT_STATUS_DEPOSITED,
+ DEPOSIT_STATUS_PARTIAL,
+ EDIT_SE_IRI,
+ EM_IRI,
+)
from swh.deposit.models import Deposit, DepositCollection, DepositRequest
from swh.deposit.parsers import parse_xml
from swh.deposit.tests.common import check_archive, create_arborescence_archive
@@ -294,6 +299,35 @@
assert len(requests_archive1) == 1 + 1, "New deposit request metadata got added"
+def test_post_metadata_empty_post_finalize_deposit_ok(
+ authenticated_client,
+ deposit_collection,
+ partial_deposit_with_metadata,
+ atom_dataset,
+):
+ """Empty atom post entry with header in-progress to false transitions deposit to
+ 'deposited' status
+
+ Response: 200
+
+ """
+ deposit = partial_deposit_with_metadata
+ assert deposit.status == DEPOSIT_STATUS_PARTIAL
+
+ update_uri = reverse(EDIT_SE_IRI, args=[deposit_collection.name, deposit.id])
+ response = authenticated_client.post(
+ update_uri,
+ content_type="application/atom+xml;type=entry",
+ data="",
+ size=0,
+ HTTP_IN_PROGRESS=False,
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ deposit = Deposit.objects.get(pk=deposit.id)
+ assert deposit.status == DEPOSIT_STATUS_DEPOSITED
+
+
def test_add_metadata_to_unknown_deposit(
deposit_collection, authenticated_client, atom_dataset
):

File Metadata

Mime Type
text/plain
Expires
Dec 20 2024, 7:03 AM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3215873

Event Timeline