예제 #1
0
def test_async_iterable_payload_default_content_type() -> None:
    async def gen():
        return
        yield

    p = payload.AsyncIterablePayload(gen())
    assert p.content_type == 'application/octet-stream'
예제 #2
0
def test_async_iterable_payload_explicit_content_type() -> None:
    async def gen():
        return
        yield

    p = payload.AsyncIterablePayload(gen(), content_type='application/custom')
    assert p.content_type == 'application/custom'
예제 #3
0
def test_async_iterable_payload_explicit_content_type() -> None:
    async def gen() -> AsyncIterator[bytes]:
        return
        yield b"abc"

    p = payload.AsyncIterablePayload(gen(), content_type="application/custom")
    assert p.content_type == "application/custom"
예제 #4
0
def test_async_iterable_payload_default_content_type() -> None:
    async def gen() -> AsyncIterator[bytes]:
        return
        yield b"abc"

    p = payload.AsyncIterablePayload(gen())
    assert p.content_type == "application/octet-stream"
예제 #5
0
def test_async_iterable_payload_default_content_type() -> None:
    @async_generator
    async def gen():
        pass

    p = payload.AsyncIterablePayload(gen())
    assert p.content_type == 'application/octet-stream'
예제 #6
0
def test_async_iterable_payload_explicit_content_type() -> None:
    @async_generator
    async def gen():
        pass

    p = payload.AsyncIterablePayload(gen(), content_type='application/custom')
    assert p.content_type == 'application/custom'
예제 #7
0
def test_async_iterable_payload_not_async_iterable() -> None:

    with pytest.raises(TypeError):
        payload.AsyncIterablePayload(object())