Remove HTML-to-Markdown parser and PDF generation functionality, clean up unused imports and whitespace

This commit is contained in:
2025-12-14 20:42:02 -05:00
parent 8db38ca75e
commit 6c83ada7d1
11 changed files with 969 additions and 1578 deletions
+38 -9
View File
@@ -6,11 +6,11 @@ and that the PDF generator returns a non-empty PDF payload.
from __future__ import annotations
import os
import sys
from pathlib import Path
import pytest
from fastapi.testclient import TestClient
# Ensure project root on path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
@@ -18,10 +18,16 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
@pytest.mark.asyncio
async def test_help_markdown_builder_exists_and_non_empty():
from app import app_optimized # type: ignore
from app import create_app
assert hasattr(app_optimized, "_build_help_markdown")
md = app_optimized._build_help_markdown()
app = create_app()
client = TestClient(app)
resp = client.get(
"/api/help/documentation.md",
headers={"X-API-Key": "dev-key-1234567890"},
)
assert resp.status_code == 200
md = resp.text
assert isinstance(md, str)
assert len(md) > 100
assert "Guide d'Utilisation" in md or "Démarrage Rapide" in md
@@ -31,19 +37,42 @@ async def test_help_markdown_builder_exists_and_non_empty():
async def test_help_pdf_generator_returns_pdf_bytes():
pytest.importorskip("reportlab")
pytest.importorskip("PIL")
from app import app_optimized # type: ignore
md = app_optimized._build_help_markdown()
pdf_bytes = app_optimized._markdown_to_pdf_bytes(md)
from app import create_app
app = create_app()
client = TestClient(app)
resp = client.get(
"/api/help/documentation.pdf",
headers={"X-API-Key": "dev-key-1234567890"},
)
assert resp.status_code == 200
pdf_bytes = resp.content
assert isinstance(pdf_bytes, (bytes, bytearray))
assert len(pdf_bytes) > 1000
assert bytes(pdf_bytes[:4]) == b"%PDF"
def test_help_routes_registered():
from app.app_optimized import app # type: ignore
from app import create_app
app = create_app()
paths = {r.path for r in app.routes}
assert "/api/help/content" in paths
assert "/api/help/documentation.md" in paths
assert "/api/help/documentation.pdf" in paths
def test_help_content_endpoint_returns_html_and_toc():
from app import create_app
app = create_app()
client = TestClient(app)
resp = client.get(
"/api/help/content",
headers={"X-API-Key": "dev-key-1234567890"},
)
assert resp.status_code == 200
data = resp.json()
assert isinstance(data.get("content"), str)
assert isinstance(data.get("toc"), str)
assert "help-quickstart" in data["toc"]