Page MenuHomeSoftware Heritage

D5783.diff
No OneTemporary

D5783.diff

diff --git a/swh/deposit/api/collection.py b/swh/deposit/api/collection.py
--- a/swh/deposit/api/collection.py
+++ b/swh/deposit/api/collection.py
@@ -70,7 +70,7 @@
content_type="application/xml",
status=status.HTTP_200_OK,
)
- response._headers["Link"] = ",".join(links)
+ response["Link"] = ",".join(links)
return response
def get_queryset(self):
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
@@ -1167,7 +1167,7 @@
content_type="application/xml",
status=status,
)
- response._headers["location"] = "Location", iris[iri_key] # type: ignore
+ response["Location"] = iris[iri_key]
return response
@abstractmethod
diff --git a/swh/deposit/tests/api/test_collection_list.py b/swh/deposit/tests/api/test_collection_list.py
--- a/swh/deposit/tests/api/test_collection_list.py
+++ b/swh/deposit/tests/api/test_collection_list.py
@@ -68,7 +68,7 @@
assert (
data["swh:count"] == "2"
) # total result of 2 deposits if consuming all results
- header_link = parse_header_links(response._headers["Link"])
+ header_link = parse_header_links(response["Link"])
assert len(header_link) == 1 # only 1 next link
expected_next = f"{url}?page=2&page_size=1"
assert header_link[0]["url"].endswith(expected_next)
@@ -88,7 +88,7 @@
assert data2["swh:count"] == "2" # still total of 2 deposits across all results
expected_previous = f"{url}?page_size=1"
- header_link2 = parse_header_links(response2._headers["Link"])
+ header_link2 = parse_header_links(response2["Link"])
assert len(header_link2) == 1 # only 1 previous link
assert header_link2[0]["url"].endswith(expected_previous)
assert header_link2[0]["rel"] == "previous"
@@ -107,7 +107,7 @@
deposits3 = data3["atom:entry"] # list here
assert isinstance(deposits3, list)
assert len(deposits3) == 2
- header_link3 = parse_header_links(response3._headers["Link"])
+ header_link3 = parse_header_links(response3["Link"])
assert header_link3 == [] # no pagination as all results received in one round
assert deposit in deposits3
assert deposit2 in deposits3
diff --git a/swh/deposit/tests/api/test_collection_post_binary.py b/swh/deposit/tests/api/test_collection_post_binary.py
--- a/swh/deposit/tests/api/test_collection_post_binary.py
+++ b/swh/deposit/tests/api/test_collection_post_binary.py
@@ -127,10 +127,7 @@
edit_iri = reverse_strict("edit_iri", args=[deposit_collection.name, deposit.id])
- assert response._headers["location"] == (
- "Location",
- "http://testserver" + edit_iri,
- )
+ assert response["location"] == f"http://testserver{edit_iri}"
def test_post_deposit_binary_failure_unsupported_packaging_header(
diff --git a/swh/deposit/tests/api/test_collection_post_multipart.py b/swh/deposit/tests/api/test_collection_post_multipart.py
--- a/swh/deposit/tests/api/test_collection_post_multipart.py
+++ b/swh/deposit/tests/api/test_collection_post_multipart.py
@@ -232,7 +232,7 @@
)
assert deposit_request.raw_metadata == data_atom_entry
- replace_metadata_uri = response._headers["location"][1]
+ replace_metadata_uri = response["location"]
response = authenticated_client.put(
replace_metadata_uri,
content_type="application/atom+xml;type=entry",
diff --git a/swh/deposit/tests/api/test_deposit_private_read_archive.py b/swh/deposit/tests/api/test_deposit_private_read_archive.py
--- a/swh/deposit/tests/api/test_deposit_private_read_archive.py
+++ b/swh/deposit/tests/api/test_deposit_private_read_archive.py
@@ -40,7 +40,7 @@
response = authenticated_client.get(url)
assert response.status_code == status.HTTP_200_OK
- assert response._headers["content-type"][1] == "application/tar"
+ assert response["content-type"] == "application/tar"
# write the response stream in a temporary archive
archive_path = join(tmp_path, f"archive_{i}.tar")
@@ -85,7 +85,7 @@
response = authenticated_client.get(url)
assert response.status_code == status.HTTP_200_OK
- assert response._headers["content-type"][1] == "application/tar"
+ assert response["content-type"] == "application/tar"
# write the response stream in a temporary archive
archive_path = join(tmp_path, f"archive_{i}.tar")
with open(archive_path, "wb") as f:
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
@@ -59,7 +59,7 @@
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._headers["content-type"][1] == "application/json"
+ assert response["content-type"] == "application/json"
actual_data = response.json()
assert actual_data == {
"origin": {
@@ -132,7 +132,7 @@
response = authenticated_client.get(url)
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()
assert actual_data == {
"origin": {
@@ -207,7 +207,7 @@
response = authenticated_client.get(url)
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()
assert actual_data == {
"origin": {
@@ -268,7 +268,7 @@
response = authenticated_client.get(url)
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()
assert actual_data == {
@@ -337,7 +337,7 @@
response = authenticated_client.get(url)
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()
assert actual_data == {

File Metadata

Mime Type
text/plain
Expires
Sun, Aug 17, 9:46 PM (6 d, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217320

Event Timeline