Beispiel #1
0
async def test_body_stream_single_chunk() -> None:
    body = Body(None, None)
    body.append(b"data")
    body.set_complete()

    async def _check_data() -> None:
        async for data in body:
            assert data == b"data"

    await asyncio.wait_for(_check_data(), 1)
Beispiel #2
0
def test_body_exceeds_max_content_length() -> None:
    max_content_length = 5
    body = Body(max_content_length)
    with pytest.raises(RequestEntityTooLarge):
        body.append(b' ' * (max_content_length + 1))
Beispiel #3
0
async def _fill_body(body: Body, semaphore: asyncio.Semaphore,
                     limit: int) -> None:
    for number in range(limit):
        body.append(b"%d" % number)
        await semaphore.acquire()
    body.set_complete()
Beispiel #4
0
async def test_body_exceeds_max_content_length() -> None:
    max_content_length = 5
    body = Body(None, max_content_length)
    body.append(b" " * (max_content_length + 1))
    with pytest.raises(RequestEntityTooLarge):
        await body