Files
fn_registry/python/functions/infra/pdf_add_page_test.py
T
egutierrez df424f2de0 feat: issue/0020 — generacion de PDFs en Python y Go
Añade 3 tipos Python (PDFDoc, PDFPage, PDFStyle) y 10 funciones Python
para construir PDFs con fpdf2 (builder fluent), fusionar PDFs con pypdf
y convertir HTML/Markdown a PDF via weasyprint (stub si no disponible).
Añade pdf_simple_report en Go como stub hasta que go-pdf/fpdf se integre.

- python/types/infra/: pdf_doc, pdf_page, pdf_style
- python/functions/infra/: pdf_create, pdf_add_page, pdf_add_text,
  pdf_add_table, pdf_add_image, pdf_add_header_footer, pdf_from_html,
  pdf_from_markdown, pdf_merge, pdf_save
- functions/infra/pdf_simple_report.go: stub Go con ReportSection/ReportTable
- 17 tests Python pasando (pytest)
- fpdf2 y pypdf añadidos via uv al venv Python

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 02:02:51 +02:00

34 lines
945 B
Python

"""Tests para pdf_add_page."""
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "python", "types", "infra"))
from pdf_create import pdf_create
from pdf_add_page import pdf_add_page
def test_anadir_pagina_portrait_a4():
doc = pdf_create()
doc = pdf_add_page(doc, orientation="portrait")
assert len(doc.pages) == 1
assert doc.pages[0]["orientation"] == "portrait"
assert doc.fpdf.page == 1
def test_anadir_pagina_landscape():
doc = pdf_create()
doc = pdf_add_page(doc, orientation="landscape")
assert len(doc.pages) == 1
assert doc.pages[0]["orientation"] == "landscape"
def test_pagina_con_dimensiones_personalizadas():
doc = pdf_create()
doc = pdf_add_page(doc, width=148.0, height=210.0) # A5
assert len(doc.pages) == 1
# Verificar que se añadio la pagina
assert doc.fpdf.page == 1