Changeset View
Standalone View
swh/deposit/tests/api/test_deposit_update.py
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | ): | ||||
assert raw_metadata0 != raw_metadata1 | assert raw_metadata0 != raw_metadata1 | ||||
assert request_meta0 != request_meta1 | assert request_meta0 != request_meta1 | ||||
# check we did not touch the other parts | # check we did not touch the other parts | ||||
requests_archive1 = DepositRequest.objects.filter(deposit=deposit, type="archive") | requests_archive1 = DepositRequest.objects.filter(deposit=deposit, type="archive") | ||||
assert len(requests_archive1) == 1 | assert len(requests_archive1) == 1 | ||||
assert set(requests_archive0) == set(requests_archive1) | assert set(requests_archive0) == set(requests_archive1) | ||||
moranegg: would change to:
test_put_update_metadata_done_deposit_failure_empty_xml | |||||
Done Inline Actionsno, the comment is wrong this time, i've fixed it locally, the empty test is not related to this change (it's already in D4013). ardumont: no, the comment is wrong this time, i've fixed it locally, the empty test is not related to… | |||||
def test_add_archive_to_deposit_is_possible( | def test_add_archive_to_deposit_is_possible( | ||||
tmp_path, | tmp_path, | ||||
authenticated_client, | authenticated_client, | ||||
deposit_collection, | deposit_collection, | ||||
partial_deposit_with_metadata, | partial_deposit_with_metadata, | ||||
sample_archive, | sample_archive, | ||||
): | ): | ||||
"""Add another archive to a deposit return a 201 response | """Add another archive to a deposit return a 201 response | ||||
Not Done Inline Actionswould add a test with a full xml, missing the mandatory fields with an assert for each field. moranegg: would add a test with a full xml, missing the mandatory fields with an assert for each field. | |||||
Done Inline ActionsThe exhaustiveness in checks should not be here, it should be for the check_metadata (and it should already be covered by the tests i've moved around). ardumont: The exhaustiveness in checks should not be here, it should be for the `check_metadata` (and it… | |||||
Not Done Inline ActionsNitpick, change: (to emphasis that deposit without them fails) moranegg: Nitpick, change:
incomplete metadata
To:
without required metadata fields
(to emphasis that… | |||||
Done Inline Actionsdone Also, i've never actually explicit that but i'm trying to summarize those docstrings into oneliner... I think i'm gonna relax this now. ardumont: done
----
Also, i've never actually explicit that but i'm trying to summarize those… | |||||
""" | """ | ||||
tmp_path = str(tmp_path) | tmp_path = str(tmp_path) | ||||
deposit = partial_deposit_with_metadata | deposit = partial_deposit_with_metadata | ||||
requests = DepositRequest.objects.filter(deposit=deposit, type="archive") | requests = DepositRequest.objects.filter(deposit=deposit, type="archive") | ||||
assert len(requests) == 1 | assert len(requests) == 1 | ||||
check_archive(sample_archive["name"], requests[0].archive.name) | check_archive(sample_archive["name"], requests[0].archive.name) | ||||
requests_meta0 = DepositRequest.objects.filter(deposit=deposit, type="metadata") | requests_meta0 = DepositRequest.objects.filter(deposit=deposit, type="metadata") | ||||
assert len(requests_meta0) == 1 | assert len(requests_meta0) == 1 | ||||
Not Done Inline Actionsis it really : moranegg: is it really :
`# no title, nor author, nor name fields`
or :
`# empty xml` | |||||
Done Inline Actionsfor the specific case i chose, yes, it is. ardumont: for the specific case i chose, yes, it is.
The empty case was dealt with before in D4013. | |||||
Not Done Inline Actionschange to # no (title / name) of the software and no author resumes the check that is done with the alternative fields moranegg: change to # no (title / name) of the software and no author
resumes the check that is done… | |||||
update_uri = reverse(EM_IRI, args=[deposit_collection.name, deposit.id]) | update_uri = reverse(EM_IRI, args=[deposit_collection.name, deposit.id]) | ||||
external_id = "some-external-id-1" | external_id = "some-external-id-1" | ||||
archive2 = create_arborescence_archive( | archive2 = create_arborescence_archive( | ||||
tmp_path, "archive2", "file2", b"some other content in file" | tmp_path, "archive2", "file2", b"some other content in file" | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 589 Lines • ▼ Show 20 Lines | response = authenticated_client.put( | ||||
update_uri, | update_uri, | ||||
content_type="application/atom+xml;type=entry", | content_type="application/atom+xml;type=entry", | ||||
data=atom_dataset["entry-data-empty-body"], | data=atom_dataset["entry-data-empty-body"], | ||||
HTTP_X_CHECK_SWHID=complete_deposit.swh_id, | HTTP_X_CHECK_SWHID=complete_deposit.swh_id, | ||||
) | ) | ||||
assert response.status_code == status.HTTP_400_BAD_REQUEST | assert response.status_code == status.HTTP_400_BAD_REQUEST | ||||
assert b"Empty body request is not supported" in response.content | assert b"Empty body request is not supported" in response.content | ||||
def test_put_update_metadata_done_deposit_failure_functional_checks( | |||||
tmp_path, | |||||
authenticated_client, | |||||
complete_deposit, | |||||
deposit_collection, | |||||
atom_dataset, | |||||
swh_storage, | |||||
): | |||||
"""failure: client updates metadata on deposit done without required incomplete metadata | |||||
Response: 400 | |||||
""" | |||||
update_uri = reverse( | |||||
EDIT_SE_IRI, args=[deposit_collection.name, complete_deposit.id] | |||||
) | |||||
response = authenticated_client.put( | |||||
update_uri, | |||||
content_type="application/atom+xml;type=entry", | |||||
# no title, nor author, nor name fields | |||||
data=atom_dataset["entry-data-fail-metadata-functional-checks"], | |||||
HTTP_X_CHECK_SWHID=complete_deposit.swh_id, | |||||
) | |||||
assert response.status_code == status.HTTP_400_BAD_REQUEST | |||||
assert b"Functional metadata checks failure" in response.content | |||||
# detail on the errors | |||||
assert b"- Mandatory fields are missing (author)" in response.content | |||||
assert ( | |||||
b"- Mandatory alternate fields are missing (name or title)" in response.content | |||||
) |
would change to:
test_put_update_metadata_done_deposit_failure_empty_xml