"""Measurement fixture for a document of roughly twelve hundred pages. Marked slow on purpose. It is here to measure memory and wall clock time of the chunked pipeline, not to assert exact numbers. """ from __future__ import annotations import time import pytest pytest.importorskip("weasyprint") from app.config import Settings # noqa: E402 from app.engines.weasy import WeasyPrintEngine # noqa: E402 from app.models import ChunkSettings, ConvertRequest, PageNumbers, Source # noqa: E402 from app.services.pipeline import ConversionPipeline # noqa: E402 pytestmark = [pytest.mark.asyncio, pytest.mark.slow] async def test_large_document_renders_in_chunks(tmp_path, large_document: str) -> None: pipeline = ConversionPipeline({"weasyprint": WeasyPrintEngine()}, Settings()) request = ConvertRequest( source=Source(html=large_document), engine="weasyprint", page_numbers=PageNumbers(enabled=True), chunking=ChunkSettings(enabled=True, pages_per_chunk=50), ) started = time.monotonic() result = await pipeline.run(request, tmp_path) duration = time.monotonic() - started print(f"stranek: {result.page_count}, cas: {duration:.1f} s") assert result.page_count > 1000 assert result.path.exists()