routeur_ia_api / tests /test_pdf_generation.py
Cyril Dupland
Enhance PDF generation and update configurations: Add PDF_LOGO_PATH to .env.example, include markdown-pdf in requirements.txt, and refactor PDF generation logic to support logo integration. Introduce tests for PDF generation from Markdown input and update summarizer agent to streamline export functionality.
3cd0aad
raw
history blame
715 Bytes
# tests/test_pdf_generation.py
"""Test PDF generation from Markdown input (markdown-pdf)."""
from pathlib import Path
from tools.pdf import markdown_to_pdf
_DIR = Path(__file__).resolve().parent
MD_INPUT_PATH = _DIR / "ai_synthesis_response.md"
PDF_OUTPUT_PATH = _DIR / "ai_synthesis_response.pdf"
def test_generates_pdf_from_markdown_locally():
"""Generate a PDF from markdown input and verify it is written locally."""
md_input = MD_INPUT_PATH.read_text(encoding="utf-8")
buffer = markdown_to_pdf(md_input)
PDF_OUTPUT_PATH.write_bytes(buffer.getvalue())
assert PDF_OUTPUT_PATH.exists()
assert PDF_OUTPUT_PATH.stat().st_size > 0
assert PDF_OUTPUT_PATH.read_bytes()[:4] == b"%PDF"