Repository: cppa-cursor-browser
Assignee: Brad @bradjin8
Points: 3
Severity: Medium
Problem
The PDF export endpoint (api/pdf.py) has no dedicated unit tests. The endpoint generates PDF output via fpdf2 from conversation data, but its rendering correctness, error handling for missing/malformed conversations, and edge cases (empty conversations, very long content, Unicode characters) are unverified. The eval notes this as part of the broader "Unverified Pipeline" — the best-tested code is at the boundaries while interior pipeline paths lack dedicated coverage.
Acceptance Criteria
Implementation Notes
Follow the pattern of existing API tests in tests/. Use Flask's test_client() to make requests to the PDF endpoint. For PDF validation, a simple check is sufficient: verify the response starts with %PDF- (the PDF magic bytes) or use fpdf2's own parsing if available. Mock the service layer to provide controlled conversation data. The fpdf2 library (pinned with Pillow >=12.2.0,<13 per CVE comment in pyproject.toml) handles the actual PDF generation — focus tests on the endpoint's integration of data retrieval and PDF rendering, not on fpdf2 internals.
References
- Eval finding: Test 30 (Test Presence) — part of the "Unverified Dark Path" compound
- Related files:
api/pdf.py, tests/ (existing API test files for reference patterns)
Repository: cppa-cursor-browser
Assignee: Brad @bradjin8
Points: 3
Severity: Medium
Problem
The PDF export endpoint (
api/pdf.py) has no dedicated unit tests. The endpoint generates PDF output viafpdf2from conversation data, but its rendering correctness, error handling for missing/malformed conversations, and edge cases (empty conversations, very long content, Unicode characters) are unverified. The eval notes this as part of the broader "Unverified Pipeline" — the best-tested code is at the boundaries while interior pipeline paths lack dedicated coverage.Acceptance Criteria
tests/test_pdf_export.py(or equivalent) is createdapplication/pdf), non-empty response body, and that the PDF is valid (parseable by a basic check)Implementation Notes
Follow the pattern of existing API tests in
tests/. Use Flask'stest_client()to make requests to the PDF endpoint. For PDF validation, a simple check is sufficient: verify the response starts with%PDF-(the PDF magic bytes) or usefpdf2's own parsing if available. Mock the service layer to provide controlled conversation data. Thefpdf2library (pinned with Pillow>=12.2.0,<13per CVE comment inpyproject.toml) handles the actual PDF generation — focus tests on the endpoint's integration of data retrieval and PDF rendering, not onfpdf2internals.References
api/pdf.py,tests/(existing API test files for reference patterns)