Initial commit — Performance West telecom compliance platform
Includes: API (Express/TypeScript), Astro site, Python workers, document generators, FCC compliance tools, Canada CRTC formation, Ansible infrastructure, and deployment scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
f8cd37ac8c
1823 changed files with 145167 additions and 0 deletions
74
scripts/tests/test_binder.py
Normal file
74
scripts/tests/test_binder.py
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
"""Test binder compilation: CRTC letter DOCX → PDF → corporate binder."""
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
work = tempfile.mkdtemp(prefix="pw_binder_test_")
|
||||
print(f"Work dir: {work}")
|
||||
|
||||
# Step 1: Generate CRTC letter DOCX
|
||||
print("\n1. Generating CRTC letter DOCX...")
|
||||
from scripts.document_gen.templates.crtc_letter_generator import generate_crtc_letter
|
||||
docx = generate_crtc_letter(
|
||||
entity_name="E2E Test Carrier Corp.",
|
||||
incorporation_number="BC1234567",
|
||||
registered_office="329 Howe St, Vancouver, BC V6C 3N2",
|
||||
services_description="VoIP services",
|
||||
geographic_coverage="Canada-wide",
|
||||
include_bits=True,
|
||||
regulatory_contact_name="Test Director",
|
||||
director_name="Test Director",
|
||||
ca_domain="e2e-test.ca",
|
||||
output_path=os.path.join(work, "crtc_letter.docx"),
|
||||
)
|
||||
print(f" DOCX: {os.path.getsize(docx)} bytes")
|
||||
|
||||
# Step 2: Convert to PDF via LibreOffice
|
||||
print("\n2. Converting DOCX → PDF (LibreOffice)...")
|
||||
ret = os.system(f"libreoffice --headless --convert-to pdf --outdir {work} {docx} >/dev/null 2>&1")
|
||||
pdf_path = os.path.join(work, "crtc_letter.pdf")
|
||||
if not os.path.exists(pdf_path):
|
||||
print(" FAIL: PDF not created")
|
||||
sys.exit(1)
|
||||
print(f" PDF: {os.path.getsize(pdf_path)} bytes")
|
||||
|
||||
# Step 3: Compile binder
|
||||
print("\n3. Compiling corporate binder...")
|
||||
from scripts.workers.binder_compiler import BinderCompiler
|
||||
compiler = BinderCompiler()
|
||||
binder = compiler.compile(
|
||||
entity_name="E2E Test Carrier Corp.",
|
||||
incorporation_number="BC1234567",
|
||||
order_number="CA-2026-BINDERTEST",
|
||||
pdf_paths=[pdf_path],
|
||||
output_dir=work,
|
||||
sections=["CRTC Notification Letter"],
|
||||
)
|
||||
|
||||
if not binder or not os.path.exists(binder):
|
||||
print(f" FAIL: Binder compilation returned {binder}")
|
||||
sys.exit(1)
|
||||
|
||||
size = os.path.getsize(binder)
|
||||
print(f" Binder: {size} bytes")
|
||||
|
||||
# Step 4: Verify
|
||||
with open(binder, "rb") as f:
|
||||
header = f.read(5)
|
||||
print(f" PDF header: {header}")
|
||||
|
||||
try:
|
||||
import pikepdf
|
||||
with pikepdf.open(binder) as pdf:
|
||||
pages = len(pdf.pages)
|
||||
print(f" Pages: {pages}")
|
||||
print(f" Expected: cover + TOC + divider + letter = 4+ pages")
|
||||
if pages >= 4:
|
||||
print("\n PASS: Binder compiled with all sections")
|
||||
else:
|
||||
print(f"\n WARN: Only {pages} pages (expected 4+)")
|
||||
except ImportError:
|
||||
print(" (pikepdf not available for page count)")
|
||||
|
||||
print(f"\n Output: {binder}")
|
||||
print(" DONE")
|
||||
Loading…
Add table
Add a link
Reference in a new issue