Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_collection_post_binary.py
# Copyright (C) 2017-2019 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 | ||||
"""Tests the handling of the binary content when doing a POST Col-IRI.""" | """Tests the handling of the binary content when doing a POST Col-IRI.""" | ||||
from io import BytesIO | from io import BytesIO | ||||
import uuid | import uuid | ||||
from django.urls import reverse | from django.urls import reverse_lazy as reverse | ||||
import pytest | import pytest | ||||
from rest_framework import status | from rest_framework import status | ||||
from swh.deposit.config import COL_IRI, DEPOSIT_STATUS_DEPOSITED | from swh.deposit.config import COL_IRI, DEPOSIT_STATUS_DEPOSITED | ||||
from swh.deposit.models import Deposit, DepositRequest | from swh.deposit.models import Deposit, DepositRequest | ||||
from swh.deposit.parsers import parse_xml | from swh.deposit.parsers import parse_xml | ||||
from swh.deposit.tests.common import ( | from swh.deposit.tests.common import ( | ||||
check_archive, | check_archive, | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | ): | ||||
assert int(response_content["swh:deposit_id"]) == deposit.id | assert int(response_content["swh:deposit_id"]) == deposit.id | ||||
assert response_content["swh:deposit_status"] == deposit.status | assert response_content["swh:deposit_status"] == deposit.status | ||||
# deprecated tags | # deprecated tags | ||||
assert response_content["atom:deposit_archive"] == sample_archive["name"] | assert response_content["atom:deposit_archive"] == sample_archive["name"] | ||||
assert int(response_content["atom:deposit_id"]) == deposit.id | assert int(response_content["atom:deposit_id"]) == deposit.id | ||||
assert response_content["atom:deposit_status"] == deposit.status | assert response_content["atom:deposit_status"] == deposit.status | ||||
edit_iri = reverse("edit_iri", args=[deposit_collection.name, deposit.id]) | from django.urls import reverse as reverse_strict | ||||
edit_iri = reverse_strict("edit_iri", args=[deposit_collection.name, deposit.id]) | |||||
assert response._headers["location"] == ( | assert response._headers["location"] == ( | ||||
"Location", | "Location", | ||||
"http://testserver" + edit_iri, | "http://testserver" + edit_iri, | ||||
) | ) | ||||
def test_post_deposit_binary_failure_unsupported_packaging_header( | def test_post_deposit_binary_failure_unsupported_packaging_header( | ||||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |