Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_binary.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2019 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 | ||||
import pytest | import pytest | ||||
from django.core.files.uploadedfile import InMemoryUploadedFile | from django.core.files.uploadedfile import InMemoryUploadedFile | ||||
from django.urls import reverse | from django.urls import reverse | ||||
from io import BytesIO | from io import BytesIO | ||||
from rest_framework import status | from rest_framework import status | ||||
from swh.deposit.tests import TEST_CONFIG | |||||
from swh.deposit.config import ( | from swh.deposit.config import ( | ||||
COL_IRI, EM_IRI, DEPOSIT_STATUS_DEPOSITED, | COL_IRI, EM_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 create_arborescence_archive, check_archive | from swh.deposit.tests.common import create_arborescence_archive, check_archive | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | def test_post_deposit_binary_upload_fail_if_upload_size_limit_exceeded( | ||||
"""Binary upload must not exceed the limit set up... | """Binary upload must not exceed the limit set up... | ||||
""" | """ | ||||
tmp_path = str(tmp_path) | tmp_path = str(tmp_path) | ||||
url = reverse(COL_IRI, args=[deposit_collection.name]) | url = reverse(COL_IRI, args=[deposit_collection.name]) | ||||
archive = create_arborescence_archive( | archive = create_arborescence_archive( | ||||
tmp_path, 'archive2', 'file2', b'some content in file', | tmp_path, 'archive2', 'file2', b'some content in file', | ||||
up_to_size=TEST_CONFIG['max_upload_size']) | up_to_size=500) | ||||
external_id = 'some-external-id' | external_id = 'some-external-id' | ||||
# when | # when | ||||
response = authenticated_client.post( | response = authenticated_client.post( | ||||
url, | url, | ||||
content_type='application/zip', | content_type='application/zip', | ||||
data=archive['data'], | data=archive['data'], | ||||
▲ Show 20 Lines • Show All 309 Lines • Show Last 20 Lines |