amine-yagoub commited on
Commit
62e653c
·
1 Parent(s): 2e03441

test: add export pdf functionality tests

Browse files
Files changed (1) hide show
  1. tests/test_pdf_export.py +20 -0
tests/test_pdf_export.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Test PDF export from the UI exports module."""
2
+
3
+ from code_tribunal.ui.exports import export_pdf
4
+
5
+
6
+ def test_export_pdf_generates_file():
7
+ """export_pdf should produce a non-empty PDF file from a context dict."""
8
+ ctx = {
9
+ "evidence": "## Evidence\n\n- Finding 1: hardcoded password in config.py:42",
10
+ "verdict": "## Verdict\n\nOverall: GUILTY\nRisk Score: 78/100",
11
+ "report": "## Final Report\n\nExecutive Summary: Code contains critical security vulnerabilities.",
12
+ }
13
+
14
+ pdf_path = export_pdf(ctx)
15
+
16
+ from pathlib import Path
17
+ assert Path(pdf_path).exists(), f"PDF not created at {pdf_path}"
18
+ size = Path(pdf_path).stat().st_size
19
+ assert size > 500, f"PDF is too small ({size} bytes), likely broken"
20
+ print(f"\nPDF generated: {pdf_path} ({size:,} bytes)")