test: add PDF export endpoint coverage and run in CI (closes #72)#82
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds comprehensive unit tests for the PDF export endpoint. It updates the CI workflow to run the new test module, introduces a ChangesPDF Export Endpoint Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
models/from_dict_validation.py — add a small tests/test_from_dict_validation.py asserting message text for require_non_empty_str_fields / require_non_empty_str_field: absent key → missing required field, wrong type → invalid field. test_schema_error_message_distinguishes_missing_from_invalid covers the contract generically but not these helpers post-f846aaf.models/from_dict_validation.py:69 — expand require_truthy docstring to note falsy values (None, "", 0) are treated as missing (matches prior CliSessionMeta behavior). |
both findings are already satisfied on the current tree
|
|
Agree with this option in the scope of PR. |
Summary
tests/test_pdf_export.pywith 8 Flask test-client cases forPOST /api/generate-pdf: normal markdown export, empty body defaults, unsafe title filename sanitization, empty markdown, long content, Unicode/emoji, simulated PDF engine failure (500), and malformedmarkdownpayload (500).pdf_clientfixture inconftest.pyso PDF tests do not need the fullworkspace_storagesetup.tests/test_pdf_export.pyin the CI pytest step so the new tests actually run in the matrix (previously onlytest_api_endpoints.pywas executed).Closes #72.
API note: The PDF route accepts
{ markdown, title }from the browser after client-side markdown conversion (download.js). It does not look up conversations by ID on the server; invalid tab IDs are handled by/api/workspaces/.../tabs(covered intest_api_endpoints.py). Server-side error coverage uses a mockedFPDF.outputfailure and a non-stringmarkdownfield.Test plan
python -m pytest tests/test_pdf_export.py tests/test_api_endpoints.py -vpython -m pytest tests/ -q(full suite)Summary by CodeRabbit
Tests
Chores