Skip to content

Commit 585c9f1

Browse files
committed
Add compression to test upstream API
1 parent db1eca5 commit 585c9f1

File tree

3 files changed

+104
-2
lines changed

3 files changed

+104
-2
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ dev = [
4646
"pytest-asyncio>=0.25.1",
4747
"pytest-cov>=5.0.0",
4848
"pytest>=8.3.3",
49+
"starlette-cramjam>=0.4.0",
4950
]
5051

5152
[tool.pytest.ini_options]
5253
asyncio_default_fixture_loop_scope = "function"
53-
asyncio_mode = "auto"
54+
asyncio_mode = "auto"

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import uvicorn
1111
from fastapi import FastAPI
1212
from jwcrypto import jwk, jwt
13+
from starlette_cramjam.middleware import CompressionMiddleware
1314
from utils import single_chunk_async_stream_response
1415

1516

@@ -69,6 +70,8 @@ def source_api():
6970
"""Create upstream API for testing purposes."""
7071
app = FastAPI(docs_url="/api.html", openapi_url="/api")
7172

73+
app.add_middleware(CompressionMiddleware, minimum_size=0, compression_level=1)
74+
7275
for path, methods in {
7376
"/": [
7477
"GET",
@@ -118,7 +121,7 @@ def source_api():
118121
return app
119122

120123

121-
@pytest.fixture(scope="session")
124+
@pytest.fixture
122125
def source_api_server(source_api):
123126
"""Run the source API in a background thread."""
124127
host, port = "127.0.0.1", 9119

0 commit comments

Comments
 (0)