Exemple #1
0
def multiform_bytes(bytes, name=''):
    with FormDataWriter() as mpwriter:
        part = payload.BytesPayload(bytes,
                                    content_type='application/octet-stream')
        part.set_content_disposition('form-data', name='file', filename=name)
        mpwriter.append_payload(part)
        return mpwriter
Exemple #2
0
def test_bytes_payload_bad_type() -> None:
    with pytest.raises(TypeError):
        payload.BytesPayload(object())
Exemple #3
0
def test_bytes_payload_explicit_content_type() -> None:
    p = payload.BytesPayload(b'data', content_type='application/custom')
    assert p.content_type == 'application/custom'
Exemple #4
0
def test_bytes_payload_default_content_type() -> None:
    p = payload.BytesPayload(b'data')
    assert p.content_type == 'application/octet-stream'
def test_bytes_payload_memoryview_correct_size() -> None:
    mv = memoryview(array.array("H", [1, 2, 3]))
    p = payload.BytesPayload(mv)
    assert p.size == 6
def test_bytes_payload_explicit_content_type() -> None:
    p = payload.BytesPayload(b"data", content_type="application/custom")
    assert p.content_type == "application/custom"