Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/conftest.py
Show All 27 Lines | from swh.deposit.config import ( | ||||
DEPOSIT_STATUS_LOAD_SUCCESS, | DEPOSIT_STATUS_LOAD_SUCCESS, | ||||
DEPOSIT_STATUS_PARTIAL, | DEPOSIT_STATUS_PARTIAL, | ||||
DEPOSIT_STATUS_REJECTED, | DEPOSIT_STATUS_REJECTED, | ||||
DEPOSIT_STATUS_VERIFIED, | DEPOSIT_STATUS_VERIFIED, | ||||
SE_IRI, | SE_IRI, | ||||
setup_django_for, | setup_django_for, | ||||
) | ) | ||||
from swh.deposit.parsers import parse_xml | from swh.deposit.parsers import parse_xml | ||||
from swh.deposit.tests.common import create_arborescence_archive | from swh.deposit.tests.common import create_arborescence_archive, post_archive | ||||
from swh.model.identifiers import DIRECTORY, REVISION, SNAPSHOT, swhid | from swh.model.identifiers import DIRECTORY, REVISION, SNAPSHOT, swhid | ||||
from swh.scheduler import get_scheduler | from swh.scheduler import get_scheduler | ||||
# mypy is asked to ignore the import statement above because setup_databases | # mypy is asked to ignore the import statement above because setup_databases | ||||
# is not part of the d.t.utils.__all__ variable. | # is not part of the d.t.utils.__all__ variable. | ||||
TEST_USER = { | TEST_USER = { | ||||
▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | def create_deposit( | ||||
deposit_status=DEPOSIT_STATUS_DEPOSITED, | deposit_status=DEPOSIT_STATUS_DEPOSITED, | ||||
in_progress=False, | in_progress=False, | ||||
): | ): | ||||
"""Create a skeleton shell deposit | """Create a skeleton shell deposit | ||||
""" | """ | ||||
url = reverse(COL_IRI, args=[collection_name]) | url = reverse(COL_IRI, args=[collection_name]) | ||||
# when | # when | ||||
response = authenticated_client.post( | response = post_archive( | ||||
authenticated_client, | |||||
url, | url, | ||||
content_type="application/zip", # as zip | sample_archive, | ||||
data=sample_archive["data"], | |||||
# + headers | |||||
CONTENT_LENGTH=sample_archive["length"], | |||||
HTTP_SLUG=external_id, | HTTP_SLUG=external_id, | ||||
HTTP_CONTENT_MD5=sample_archive["md5sum"], | |||||
HTTP_PACKAGING="http://purl.org/net/sword/package/SimpleZip", | |||||
HTTP_IN_PROGRESS=str(in_progress).lower(), | HTTP_IN_PROGRESS=str(in_progress).lower(), | ||||
HTTP_CONTENT_DISPOSITION="attachment; filename=%s" % (sample_archive["name"]), | |||||
) | ) | ||||
# then | # then | ||||
assert response.status_code == status.HTTP_201_CREATED, response.content.decode() | assert response.status_code == status.HTTP_201_CREATED, response.content.decode() | ||||
from swh.deposit.models import Deposit | from swh.deposit.models import Deposit | ||||
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"] | ||||
▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines |