Add comprehensive unit tests for invoice API endpoints #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add comprehensive unit tests for invoice API endpoints
Summary
This PR adds a comprehensive test suite for all invoice API endpoints in the backend, addressing the lack of test coverage for the frontend API client layer. The new
test_invoices_api.pyfile includes 24 unit tests that cover all CRUD operations for invoice management.Key additions:
GET /api/invoices/,GET /api/invoices/{id},POST /api/invoices/,PUT /api/invoices/{id},DELETE /api/invoices/{id}test_jwt.pyTest coverage includes:
All 31 tests now pass (24 new + 7 existing JWT tests).
Review & Testing Checklist for Human
python3 src/backend/tests/run_tests.pyandpython3 src/backend/tests/test_invoices_api.pyto verify all tests pass consistentlyRecommended test plan: After code review, run the full test suite locally, then test the actual invoice API endpoints manually with a tool like Postman to verify the tests accurately represent the real API behavior.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD A["src/backend/tests/test_invoices_api.py"]:::major-edit B["src/backend/routes/invoices.py"]:::context C["src/backend/models.py"]:::context D["src/backend/tests/test_jwt.py"]:::context E["src/backend/tests/run_tests.py"]:::context F["src/frontend/src/utils/api.js"]:::context A -->|"Tests all endpoints"| B A -->|"Uses Invoice & InvoiceItem models"| C A -->|"Follows same pattern"| D E -->|"Auto-discovers"| A F -->|"invoicesAPI methods tested"| A subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
db.session.get()instead ofQuery.get()Session Info: Requested by @JRWu (jia.wu@codeium.com)
Link to Devin run: https://app.devin.ai/sessions/02a3f281c63e47af88674cdb2a997b11