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, post_archive | from swh.deposit.tests.common import ( | ||||
create_arborescence_archive, | |||||
post_archive, | |||||
post_atom, | |||||
) | |||||
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 294 Lines • ▼ Show 20 Lines | deposit = create_deposit( | ||||
authenticated_client, | authenticated_client, | ||||
collection_name, | collection_name, | ||||
deposit_status=DEPOSIT_STATUS_PARTIAL, | deposit_status=DEPOSIT_STATUS_PARTIAL, | ||||
**kwargs, | **kwargs, | ||||
) | ) | ||||
origin_url = deposit.client.provider_url + deposit.external_id | origin_url = deposit.client.provider_url + deposit.external_id | ||||
response = authenticated_client.post( | response = post_atom( | ||||
authenticated_client, | |||||
reverse(SE_IRI, args=[collection_name, deposit.id]), | reverse(SE_IRI, args=[collection_name, deposit.id]), | ||||
content_type="application/atom+xml;type=entry", | |||||
data=atom_dataset["entry-data0"] % origin_url, | data=atom_dataset["entry-data0"] % origin_url, | ||||
HTTP_IN_PROGRESS="true", | HTTP_IN_PROGRESS="true", | ||||
) | ) | ||||
assert response.status_code == status.HTTP_201_CREATED | assert response.status_code == status.HTTP_201_CREATED | ||||
assert deposit.status == DEPOSIT_STATUS_PARTIAL | assert deposit.status == DEPOSIT_STATUS_PARTIAL | ||||
from swh.deposit.models import Deposit | from swh.deposit.models import Deposit | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | ): | ||||
) | ) | ||||
@pytest.fixture | @pytest.fixture | ||||
def partial_deposit_only_metadata( | def partial_deposit_only_metadata( | ||||
deposit_collection, authenticated_client, atom_dataset | deposit_collection, authenticated_client, atom_dataset | ||||
): | ): | ||||
response = authenticated_client.post( | response = post_atom( | ||||
authenticated_client, | |||||
reverse(COL_IRI, args=[deposit_collection.name]), | reverse(COL_IRI, args=[deposit_collection.name]), | ||||
content_type="application/atom+xml;type=entry", | |||||
data=atom_dataset["entry-data1"], | data=atom_dataset["entry-data1"], | ||||
HTTP_SLUG="external-id-partial", | HTTP_SLUG="external-id-partial", | ||||
HTTP_IN_PROGRESS=True, | HTTP_IN_PROGRESS=True, | ||||
) | ) | ||||
assert response.status_code == status.HTTP_201_CREATED | assert response.status_code == status.HTTP_201_CREATED | ||||
response_content = parse_xml(response.content) | response_content = parse_xml(response.content) | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |