added ZstdMiddleware to ebook_search

This commit is contained in:
2026-06-12 14:57:59 -04:00
parent 51855725a1
commit 66ea18af82
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
from compression import zstd
from fastapi.testclient import TestClient
from sqlalchemy import create_engine
@@ -24,6 +25,19 @@ def fake_get_postgres_engine(**_kwargs):
return create_engine("sqlite+pysqlite:///:memory:", future=True)
def test_search_page_uses_zstd_when_requested(monkeypatch) -> None:
patch_app_runtime(monkeypatch)
app = create_app()
app.state.config = EbookSearchConfig(rerank=RerankConfig(enabled=False))
with TestClient(app) as client:
response = client.get("/", headers={"accept-encoding": "zstd"})
assert response.status_code == 200
assert response.headers["content-encoding"] == "zstd"
assert b"EPUB Search" in zstd.decompress(response.content)
def test_ui_form_passes_rerank_flag_to_search_handler(monkeypatch) -> None:
captured: dict[str, object] = {}