diff --git a/swh/deposit/api/content.py b/swh/deposit/api/content.py
--- a/swh/deposit/api/content.py
+++ b/swh/deposit/api/content.py
@@ -29,8 +29,7 @@
requests = DepositRequest.objects.filter(deposit=deposit)
context = {
- "deposit_id": deposit.id,
- "status": deposit.status,
+ "deposit": deposit,
"status_detail": DEPOSIT_STATUS_DETAIL[deposit.status],
"requests": requests,
}
diff --git a/swh/deposit/templates/deposit/content.xml b/swh/deposit/templates/deposit/content.xml
--- a/swh/deposit/templates/deposit/content.xml
+++ b/swh/deposit/templates/deposit/content.xml
@@ -3,15 +3,14 @@
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:sd="https://www.softwareheritage.org/schema/2018/deposit"
>
- {{ deposit_id }}
- {{ request.date }}
- {{ status }}
+ {{ deposit.id }}
+ {{ deposit.reception_date.isoformat }}
+ {{ deposit.status }}
{{ status_detail }}
- {{ deposit_id }}
- {{ request.date }}
- {{ status }}
+ {{ deposit.id }}
+ {{ deposit.status }}
{{ status_detail }}
diff --git a/swh/deposit/templates/deposit/deposit_receipt.xml b/swh/deposit/templates/deposit/deposit_receipt.xml
--- a/swh/deposit/templates/deposit/deposit_receipt.xml
+++ b/swh/deposit/templates/deposit/deposit_receipt.xml
@@ -4,14 +4,14 @@
xmlns:sd="https://www.softwareheritage.org/schema/2018/deposit"
>
{{ deposit_id }}
- {{ deposit_date }}
+ {{ deposit_date.isoformat }}
{{ archive }}
{{ status }}
{{ deposit_id }}
- {{ deposit_date }}
+ {{ deposit_date.isoformat }}
{{ archive }}
{{ status }}
diff --git a/swh/deposit/tests/api/test_collection_post_atom.py b/swh/deposit/tests/api/test_collection_post_atom.py
--- a/swh/deposit/tests/api/test_collection_post_atom.py
+++ b/swh/deposit/tests/api/test_collection_post_atom.py
@@ -1,10 +1,11 @@
-# Copyright (C) 2017-2021 The Software Heritage developers
+# Copyright (C) 2017-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
"""Tests the handling of the Atom content when doing a POST Col-IRI."""
+import datetime
import textwrap
import uuid
import warnings
@@ -436,18 +437,27 @@
atom_entry_data = atom_dataset["entry-data0"] % origin_url
# when
+ date_before = datetime.datetime.now(tz=datetime.timezone.utc)
response = post_atom(
authenticated_client,
reverse(COL_IRI, args=[deposit_collection.name]),
data=atom_entry_data,
HTTP_IN_PROGRESS="false",
)
+ date_after = datetime.datetime.now(tz=datetime.timezone.utc)
# then
assert response.status_code == status.HTTP_201_CREATED, response.content.decode()
response_content = ElementTree.fromstring(response.content)
deposit_id = int(response_content.findtext("swh:deposit_id", namespaces=NAMESPACES))
+ assert (
+ date_before
+ <= datetime.datetime.fromisoformat(
+ response_content.findtext("swh:deposit_date", namespaces=NAMESPACES)
+ )
+ <= date_after
+ )
deposit = Deposit.objects.get(pk=deposit_id)
assert deposit.collection == deposit_collection
diff --git a/swh/deposit/tests/api/test_get_file.py b/swh/deposit/tests/api/test_get_file.py
--- a/swh/deposit/tests/api/test_get_file.py
+++ b/swh/deposit/tests/api/test_get_file.py
@@ -5,6 +5,8 @@
"""Tests 'GET File-IRI'."""
+import datetime
+
from django.urls import reverse_lazy as reverse
from rest_framework import status
@@ -20,6 +22,7 @@
"""Retrieve information on deposit should return 200 response
"""
+ now = datetime.datetime.now(tz=datetime.timezone.utc)
for deposit in [complete_deposit, partial_deposit_only_metadata]:
url = reverse(CONT_FILE_IRI, args=[deposit.collection.name, deposit.id])
@@ -37,6 +40,13 @@
actual_deposit.findtext("swh:deposit_status_detail", namespaces=NAMESPACES)
== DEPOSIT_STATUS_DETAIL[deposit.status]
)
+ assert (
+ now - datetime.timedelta(hours=1)
+ <= datetime.datetime.fromisoformat(
+ actual_deposit.findtext("swh:deposit_date", namespaces=NAMESPACES)
+ )
+ <= now
+ )
def test_api_deposit_content_unknown(
diff --git a/swh/deposit/tests/cli/test_client.py b/swh/deposit/tests/cli/test_client.py
--- a/swh/deposit/tests/cli/test_client.py
+++ b/swh/deposit/tests/cli/test_client.py
@@ -297,7 +297,7 @@
"deposit_id": "615",
"deposit_status": "partial",
"deposit_status_detail": None,
- "deposit_date": "Oct. 8, 2020, 4:57 p.m.",
+ "deposit_date": "2020-10-08T13:52:34.509655Z",
}
with open(metadata_path) as fd:
@@ -369,7 +369,7 @@
"deposit_id": "615",
"deposit_status": "partial",
"deposit_status_detail": None,
- "deposit_date": "Oct. 8, 2020, 4:57 p.m.",
+ "deposit_date": "2020-10-08T13:52:34.509655Z",
}
with open(metadata_path) as fd:
@@ -625,7 +625,7 @@
"deposit_id": "615",
"deposit_status": "partial",
"deposit_status_detail": None,
- "deposit_date": "Oct. 8, 2020, 4:57 p.m.",
+ "deposit_date": "2020-10-08T13:52:34.509655Z",
}
with open(metadata_path) as fd:
@@ -666,7 +666,7 @@
"deposit_id": str(deposit_id),
"deposit_status": "partial",
"deposit_status_detail": None,
- "deposit_date": "Oct. 8, 2020, 4:57 p.m.",
+ "deposit_date": "2020-10-08T13:52:34.509655Z",
}
# Update the partial deposit with only 1 archive
@@ -897,7 +897,7 @@
expected_deposit_status = {
"deposit_id": "100",
"deposit_status": "done",
- "deposit_date": "2020-10-08T13:52:34.509655",
+ "deposit_date": "2020-10-08T13:52:34.509655Z",
}
assert expected_deposit_status["deposit_status"] == "done"
diff --git a/swh/deposit/tests/data/https_deposit.swh.test/1_test b/swh/deposit/tests/data/https_deposit.swh.test/1_test
--- a/swh/deposit/tests/data/https_deposit.swh.test/1_test
+++ b/swh/deposit/tests/data/https_deposit.swh.test/1_test
@@ -4,13 +4,13 @@
xmlns:sd="https://www.softwareheritage.org/schema/2018/deposit"
>
615
- Oct. 8, 2020, 4:57 p.m.
+ 2020-10-08T13:52:34.509655Z
None
partial
615
- Oct. 8, 2020, 4:57 p.m.
+ 2020-10-08T13:52:34.509655Z
None
partial
diff --git a/swh/deposit/tests/data/https_deposit.test.metadata/1_test b/swh/deposit/tests/data/https_deposit.test.metadata/1_test
--- a/swh/deposit/tests/data/https_deposit.test.metadata/1_test
+++ b/swh/deposit/tests/data/https_deposit.test.metadata/1_test
@@ -4,13 +4,13 @@
xmlns:sd="https://www.softwareheritage.org/schema/2018/deposit"
>
666
- Oct. 8, 2020, 4:57 p.m.
+ 2020-10-08T13:52:34.509655Z
hardcoded_sample_archive_path
partial
666
- Oct. 8, 2020, 4:57 p.m.
+ 2020-10-08T13:52:34.509655Z
hardcoded_sample_archive_path
partial
diff --git a/swh/deposit/tests/data/https_deposit.test.metadata/1_test_666_metadata b/swh/deposit/tests/data/https_deposit.test.metadata/1_test_666_metadata
--- a/swh/deposit/tests/data/https_deposit.test.metadata/1_test_666_metadata
+++ b/swh/deposit/tests/data/https_deposit.test.metadata/1_test_666_metadata
@@ -3,13 +3,13 @@
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:sd="https://www.softwareheritage.org/schema/2018/deposit">
666
- Oct. 9, 2020, 8:44 p.m.
+ 2020-10-08T13:52:34.509655Z
something
deposited
666
- Oct. 9, 2020, 8:44 p.m.
+ 2020-10-08T13:52:34.509655Z
something
deposited
diff --git a/swh/deposit/tests/data/https_deposit.test.metadataonly/1_test b/swh/deposit/tests/data/https_deposit.test.metadataonly/1_test
--- a/swh/deposit/tests/data/https_deposit.test.metadataonly/1_test
+++ b/swh/deposit/tests/data/https_deposit.test.metadataonly/1_test
@@ -4,7 +4,7 @@
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:sd="https://www.softwareheritage.org/schema/2018/deposit">
100
- 2020-10-08T13:52:34.509655
+ 2020-10-08T13:52:34.509655Z
done
swh:1:dir:ef04a768181417fbc5eef4243e2507915f24deea
swh:1:dir:ef04a768181417fbc5eef4243e2507915f24deea;origin=https://www.softwareheritage.org/check-deposit-2020-10-08T13:52:34.509655;visit=swh:1:snp:c477c6ef51833127b13a86ece7d75e5b3cc4e93d;anchor=swh:1:rev:f26f3960c175f15f6e24200171d446b86f6f7230;path=/