Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_collection.py
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | ): | ||||
""" | """ | ||||
deposit = partial_deposit | deposit = partial_deposit | ||||
assert deposit.status == DEPOSIT_STATUS_PARTIAL | assert deposit.status == DEPOSIT_STATUS_PARTIAL | ||||
# adding a new deposit with the same external id | # adding a new deposit with the same external id | ||||
response = authenticated_client.post( | response = authenticated_client.post( | ||||
reverse(COL_IRI, args=[deposit_collection.name]), | reverse(COL_IRI, args=[deposit_collection.name]), | ||||
content_type="application/atom+xml;type=entry", | content_type="application/atom+xml;type=entry", | ||||
data=atom_dataset["entry-data0"] % deposit.external_id, | data=atom_dataset["entry-data0"], | ||||
HTTP_SLUG=deposit.external_id, | HTTP_SLUG=deposit.external_id, | ||||
) | ) | ||||
assert response.status_code == status.HTTP_201_CREATED | assert response.status_code == status.HTTP_201_CREATED | ||||
response_content = parse_xml(BytesIO(response.content)) | response_content = parse_xml(BytesIO(response.content)) | ||||
deposit_id = response_content["swh:deposit_id"] | deposit_id = response_content["swh:deposit_id"] | ||||
assert deposit_id != deposit.id # new deposit | assert deposit_id != deposit.id # new deposit | ||||
Show All 13 Lines | ): | ||||
deposit = failed_deposit | deposit = failed_deposit | ||||
assert deposit.status == DEPOSIT_STATUS_LOAD_FAILURE | assert deposit.status == DEPOSIT_STATUS_LOAD_FAILURE | ||||
# adding a new deposit with the same external id as a completed deposit | # adding a new deposit with the same external id as a completed deposit | ||||
# creates the parenting chain | # creates the parenting chain | ||||
response = authenticated_client.post( | response = authenticated_client.post( | ||||
reverse(COL_IRI, args=[deposit_collection.name]), | reverse(COL_IRI, args=[deposit_collection.name]), | ||||
content_type="application/atom+xml;type=entry", | content_type="application/atom+xml;type=entry", | ||||
data=atom_dataset["entry-data0"] % deposit.external_id, | data=atom_dataset["entry-data0"], | ||||
HTTP_SLUG=deposit.external_id, | HTTP_SLUG=deposit.external_id, | ||||
) | ) | ||||
assert response.status_code == status.HTTP_201_CREATED | assert response.status_code == status.HTTP_201_CREATED | ||||
response_content = parse_xml(BytesIO(response.content)) | response_content = parse_xml(BytesIO(response.content)) | ||||
deposit_id = response_content["swh:deposit_id"] | deposit_id = response_content["swh:deposit_id"] | ||||
assert deposit_id != deposit.id | assert deposit_id != deposit.id | ||||
Show All 14 Lines | ): | ||||
deposit = completed_deposit | deposit = completed_deposit | ||||
assert deposit.status == DEPOSIT_STATUS_LOAD_SUCCESS | assert deposit.status == DEPOSIT_STATUS_LOAD_SUCCESS | ||||
# adding a new deposit with the same external id as a completed deposit | # adding a new deposit with the same external id as a completed deposit | ||||
# creates the parenting chain | # creates the parenting chain | ||||
response = authenticated_client.post( | response = authenticated_client.post( | ||||
reverse(COL_IRI, args=[deposit_collection.name]), | reverse(COL_IRI, args=[deposit_collection.name]), | ||||
content_type="application/atom+xml;type=entry", | content_type="application/atom+xml;type=entry", | ||||
data=atom_dataset["entry-data0"] % deposit.external_id, | data=atom_dataset["entry-data0"], | ||||
HTTP_SLUG=deposit.external_id, | HTTP_SLUG=deposit.external_id, | ||||
) | ) | ||||
assert response.status_code == status.HTTP_201_CREATED | assert response.status_code == status.HTTP_201_CREATED | ||||
response_content = parse_xml(BytesIO(response.content)) | response_content = parse_xml(BytesIO(response.content)) | ||||
deposit_id = response_content["swh:deposit_id"] | deposit_id = response_content["swh:deposit_id"] | ||||
assert deposit_id != deposit.id | assert deposit_id != deposit.id | ||||
new_deposit = Deposit.objects.get(pk=deposit_id) | new_deposit = Deposit.objects.get(pk=deposit_id) | ||||
assert deposit.collection == new_deposit.collection | assert deposit.collection == new_deposit.collection | ||||
assert deposit.external_id == new_deposit.external_id | assert deposit.external_id == new_deposit.external_id | ||||
assert new_deposit != deposit | assert new_deposit != deposit | ||||
assert new_deposit.parent == deposit | assert new_deposit.parent == deposit |