0819c35bbb
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>
30 lines
968 B
Python
30 lines
968 B
Python
"""Tests para pdf_create."""
|
|
|
|
import sys
|
|
import os
|
|
|
|
sys.path.insert(0, os.path.join(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_doc import PDFDoc
|
|
|
|
|
|
def test_crear_documento_con_titulo_y_autor():
|
|
doc = pdf_create(title="Test Title", author="Test Author")
|
|
assert isinstance(doc, PDFDoc)
|
|
assert doc.title == "Test Title"
|
|
assert doc.author == "Test Author"
|
|
assert doc.fpdf is not None
|
|
|
|
|
|
def test_margenes_personalizados_aplicados():
|
|
doc = pdf_create(margin_left=15.0, margin_right=15.0, margin_top=25.0, margin_bottom=25.0)
|
|
assert doc.margin_left == 15.0
|
|
assert doc.margin_right == 15.0
|
|
assert doc.margin_top == 25.0
|
|
assert doc.margin_bottom == 25.0
|
|
# Verificar que fpdf tiene los margenes aplicados
|
|
assert abs(doc.fpdf.l_margin - 15.0) < 0.1
|
|
assert abs(doc.fpdf.r_margin - 15.0) < 0.1
|