Files
egutierrez 0819c35bbb 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

48 lines
1.3 KiB
Python

"""Tests para pdf_add_table."""
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
from pdf_add_table import pdf_add_table
from pdf_save import pdf_save
def test_tabla_con_headers_y_datos():
doc = pdf_create()
doc = pdf_add_page(doc)
headers = ["Dominio", "Funciones", "Tipos"]
rows = [
["core", "45", "12"],
["infra", "38", "8"],
["finance", "22", "6"],
]
doc = pdf_add_table(doc, headers, rows)
pdf_bytes = pdf_save(doc)
assert pdf_bytes[:4] == b"%PDF"
assert len(pdf_bytes) > 200
def test_tabla_con_col_widths_personalizados():
doc = pdf_create()
doc = pdf_add_page(doc)
headers = ["Nombre", "Valor"]
rows = [["alpha", "100"], ["beta", "200"]]
doc = pdf_add_table(doc, headers, rows, col_widths=[100.0, 70.0])
pdf_bytes = pdf_save(doc)
assert pdf_bytes[:4] == b"%PDF"
def test_tabla_sin_borde():
doc = pdf_create()
doc = pdf_add_page(doc)
headers = ["A", "B"]
rows = [["1", "2"]]
doc = pdf_add_table(doc, headers, rows, border=0)
pdf_bytes = pdf_save(doc)
assert pdf_bytes[:4] == b"%PDF"