Exemplo n.º 1
0
def test_multipart_manager_initialize_upload(
        multipart_manager: MultipartManager):
    initialization = multipart_manager.initialize_upload(
        'new-object',
        100,
    )

    assert initialization
Exemplo n.º 2
0
def test_multipart_manager_initialize_upload(
        multipart_manager: MultipartManager, content_type):
    initialization = multipart_manager.initialize_upload(
        'new-object',
        100,
        content_type=content_type,
    )

    assert initialization
Exemplo n.º 3
0
def test_multipart_manager_finalize_upload(multipart_manager: MultipartManager,
                                           file_size: int):
    initialization = multipart_manager.initialize_upload(
        'new-object',
        file_size,
    )

    finalization = UploadFinalization(object_key=initialization.object_key,
                                      upload_id=initialization.upload_id,
                                      parts=[])

    for part in initialization.parts:
        resp = requests.put(part.upload_url, data=b'a' * part.size)
        resp.raise_for_status()
        finalization.parts.append(
            PartFinalization(part_number=part.part_number,
                             size=part.size,
                             etag=resp.headers['ETag']))

    multipart_manager.finalize_upload(finalization)
Exemplo n.º 4
0
def test_multipart_manager_complete_upload(multipart_manager: MultipartManager,
                                           file_size: int):
    initialization = multipart_manager.initialize_upload(
        'new-object',
        file_size,
    )

    transferred_parts = TransferredParts(object_key=initialization.object_key,
                                         upload_id=initialization.upload_id,
                                         parts=[])

    for part in initialization.parts:
        resp = requests.put(part.upload_url, data=b'a' * part.size)
        resp.raise_for_status()
        transferred_parts.parts.append(
            TransferredPart(part_number=part.part_number,
                            size=part.size,
                            etag=resp.headers['ETag']))

    completed_upload = multipart_manager.complete_upload(transferred_parts)
    assert completed_upload
    assert completed_upload.complete_url
    assert completed_upload.body