"""Behaviour when an asset cannot be loaded. A missing image must not abort the render, but it must never disappear silently either. """ from __future__ import annotations import pytest pytest.importorskip("weasyprint") from app.config import Settings # noqa: E402 from app.engines.weasy import WeasyPrintEngine # noqa: E402 from app.models import ConvertRequest, Source # noqa: E402 from app.services.pipeline import ConversionPipeline # noqa: E402 pytestmark = pytest.mark.asyncio HTML_WITH_BLOCKED_IMAGE = """

Dokument s nedostupnym obrazkem

Text pokracuje i kdyz se obrazek nenacte.

chybi """ async def test_blocked_asset_is_reported_and_render_continues(tmp_path) -> None: pipeline = ConversionPipeline({"weasyprint": WeasyPrintEngine()}, Settings()) request = ConvertRequest( source=Source(html=HTML_WITH_BLOCKED_IMAGE), engine="weasyprint", ) result = await pipeline.run(request, tmp_path) assert result.page_count >= 1 assert result.path.exists() assert result.missing_assets, "nedostupny asset musi byt hlaseny v odpovedi" assert "127.0.0.1" in result.missing_assets[0].url