Skip to content

Commit

Permalink
add more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Nov 12, 2024
1 parent 385f2de commit eefc438
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_http_writer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Tests for aiohttp/http_writer.py
import array
import asyncio
import zlib
from typing import Any, Iterable
from unittest import mock

Expand Down Expand Up @@ -217,6 +218,23 @@ async def test_write_payload_deflate_compression_chunked_data_in_eof(
assert content == expected


async def test_write_large_payload_deflate_compression_chunked_data_in_eof(
protocol: BaseProtocol,
transport: asyncio.Transport,
loop: asyncio.AbstractEventLoop,
) -> None:
msg = http.StreamWriter(protocol, loop)
msg.enable_compression("deflate")
msg.enable_chunking()
await msg.write(b"data" * 4096)
await msg.write_eof(b"data" * 4096)

chunks = [c[1][0][1] for c in list(transport.writelines.mock_calls)] # type: ignore[attr-defined]
assert all(chunks)
content = b"".join(chunks)
assert zlib.decompress(content) == b"data" * 8192


async def test_write_payload_deflate_compression_chunked_connection_lost(
protocol: BaseProtocol,
transport: asyncio.Transport,
Expand Down

0 comments on commit eefc438

Please sign in to comment.