Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_status.py
Show All 25 Lines | def test_post_deposit_with_status_check(authenticated_client, deposited_deposit): | ||||
status_url = reverse(STATE_IRI, args=[deposit.collection.name, deposit.id]) | status_url = reverse(STATE_IRI, args=[deposit.collection.name, deposit.id]) | ||||
# check status | # check status | ||||
status_response = authenticated_client.get(status_url) | status_response = authenticated_client.get(status_url) | ||||
assert status_response.status_code == status.HTTP_200_OK | assert status_response.status_code == status.HTTP_200_OK | ||||
r = parse_xml(BytesIO(status_response.content)) | r = parse_xml(BytesIO(status_response.content)) | ||||
assert int(r["deposit_id"]) == deposit.id | assert int(r["swh:deposit_id"]) == deposit.id | ||||
assert r["deposit_status"] == DEPOSIT_STATUS_DEPOSITED | assert r["swh:deposit_status"] == DEPOSIT_STATUS_DEPOSITED | ||||
assert r["deposit_status_detail"] == DEPOSIT_STATUS_DETAIL[DEPOSIT_STATUS_DEPOSITED] | assert ( | ||||
assert r["deposit_external_id"] == deposit.external_id | r["swh:deposit_status_detail"] | ||||
== DEPOSIT_STATUS_DETAIL[DEPOSIT_STATUS_DEPOSITED] | |||||
) | |||||
assert r["swh:deposit_external_id"] == deposit.external_id | |||||
def test_status_unknown_deposit(authenticated_client, deposit_collection): | def test_status_unknown_deposit(authenticated_client, deposit_collection): | ||||
"""Unknown deposit status should return 404 response | """Unknown deposit status should return 404 response | ||||
""" | """ | ||||
unknown_deposit_id = 999 | unknown_deposit_id = 999 | ||||
status_url = reverse(STATE_IRI, args=[deposit_collection.name, unknown_deposit_id]) | status_url = reverse(STATE_IRI, args=[deposit_collection.name, unknown_deposit_id]) | ||||
Show All 20 Lines | def test_status_deposit_rejected(authenticated_client, rejected_deposit): | ||||
url = reverse(STATE_IRI, args=[deposit.collection.name, deposit.id]) | url = reverse(STATE_IRI, args=[deposit.collection.name, deposit.id]) | ||||
# when | # when | ||||
status_response = authenticated_client.get(url) | status_response = authenticated_client.get(url) | ||||
# then | # then | ||||
assert status_response.status_code == status.HTTP_200_OK | assert status_response.status_code == status.HTTP_200_OK | ||||
r = parse_xml(BytesIO(status_response.content)) | r = parse_xml(BytesIO(status_response.content)) | ||||
assert int(r["deposit_id"]) == deposit.id | assert int(r["swh:deposit_id"]) == deposit.id | ||||
assert r["deposit_status"] == DEPOSIT_STATUS_REJECTED | assert r["swh:deposit_status"] == DEPOSIT_STATUS_REJECTED | ||||
assert r["deposit_status_detail"] == "Deposit failed the checks" | assert r["swh:deposit_status_detail"] == "Deposit failed the checks" | ||||
if deposit.swhid: | if deposit.swhid: | ||||
assert r["deposit_swhid"] == deposit.swhid | assert r["swh:deposit_swhid"] == deposit.swhid | ||||
def test_status_with_http_accept_header_should_not_break( | def test_status_with_http_accept_header_should_not_break( | ||||
authenticated_client, partial_deposit | authenticated_client, partial_deposit | ||||
): | ): | ||||
"""Asking deposit status with Accept header should return 200 | """Asking deposit status with Accept header should return 200 | ||||
""" | """ | ||||
Show All 18 Lines | def test_status_complete_deposit(authenticated_client, complete_deposit): | ||||
url = reverse(STATE_IRI, args=[deposit.collection.name, deposit.id]) | url = reverse(STATE_IRI, args=[deposit.collection.name, deposit.id]) | ||||
# when | # when | ||||
status_response = authenticated_client.get(url) | status_response = authenticated_client.get(url) | ||||
# then | # then | ||||
assert status_response.status_code == status.HTTP_200_OK | assert status_response.status_code == status.HTTP_200_OK | ||||
r = parse_xml(BytesIO(status_response.content)) | r = parse_xml(BytesIO(status_response.content)) | ||||
assert int(r["deposit_id"]) == deposit.id | assert int(r["swh:deposit_id"]) == deposit.id | ||||
assert r["deposit_status"] == DEPOSIT_STATUS_LOAD_SUCCESS | assert r["swh:deposit_status"] == DEPOSIT_STATUS_LOAD_SUCCESS | ||||
assert ( | assert ( | ||||
r["deposit_status_detail"] == DEPOSIT_STATUS_DETAIL[DEPOSIT_STATUS_LOAD_SUCCESS] | r["swh:deposit_status_detail"] | ||||
== DEPOSIT_STATUS_DETAIL[DEPOSIT_STATUS_LOAD_SUCCESS] | |||||
) | ) | ||||
assert deposit.swhid is not None | assert deposit.swhid is not None | ||||
assert r["deposit_swh_id"] == deposit.swhid | assert r["swh:deposit_swh_id"] == deposit.swhid | ||||
assert deposit.swhid_context is not None | assert deposit.swhid_context is not None | ||||
assert r["deposit_swh_id_context"] == deposit.swhid_context | assert r["swh:deposit_swh_id_context"] == deposit.swhid_context |