Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_collection_reuse_slug.py
# Copyright (C) 2017-2021 The Software Heritage developers | # Copyright (C) 2017-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from io import BytesIO | from io import BytesIO | ||||
from django.urls import reverse_lazy as reverse | from django.urls import reverse_lazy as reverse | ||||
from rest_framework import status | from rest_framework import status | ||||
import xmltodict | |||||
from swh.deposit.config import ( | from swh.deposit.config import ( | ||||
COL_IRI, | COL_IRI, | ||||
DEPOSIT_STATUS_LOAD_FAILURE, | DEPOSIT_STATUS_LOAD_FAILURE, | ||||
DEPOSIT_STATUS_LOAD_SUCCESS, | DEPOSIT_STATUS_LOAD_SUCCESS, | ||||
DEPOSIT_STATUS_PARTIAL, | DEPOSIT_STATUS_PARTIAL, | ||||
SE_IRI, | SE_IRI, | ||||
) | ) | ||||
Show All 12 Lines | ): | ||||
response = post_atom( | response = post_atom( | ||||
authenticated_client, | authenticated_client, | ||||
reverse(SE_IRI, args=[deposit.collection.name, deposit.id]), | reverse(SE_IRI, args=[deposit.collection.name, deposit.id]), | ||||
data=atom_dataset["entry-data1"], | data=atom_dataset["entry-data1"], | ||||
HTTP_SLUG=deposit.external_id, | HTTP_SLUG=deposit.external_id, | ||||
) | ) | ||||
assert response.status_code == status.HTTP_400_BAD_REQUEST | assert response.status_code == status.HTTP_400_BAD_REQUEST | ||||
msg = "You can only act on deposit with status '%s'" % ( | assert ( | ||||
DEPOSIT_STATUS_PARTIAL, | xmltodict.parse(response.content)["sword:error"]["summary"] | ||||
== f"You can only act on deposit with status '{DEPOSIT_STATUS_PARTIAL}'" | |||||
) | ) | ||||
assert msg in response.content.decode("utf-8") | |||||
def test_add_deposit_when_partial_makes_new_deposit( | def test_add_deposit_when_partial_makes_new_deposit( | ||||
authenticated_client, | authenticated_client, | ||||
deposit_collection, | deposit_collection, | ||||
partial_deposit, | partial_deposit, | ||||
atom_dataset, | atom_dataset, | ||||
deposit_user, | deposit_user, | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |