-
Notifications
You must be signed in to change notification settings - Fork 1
Complete mongo db integration for delete /books/{id} #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete mongo db integration for delete /books/{id} #9
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR completes the MongoDB integration for the DELETE /books/{id} endpoint by replacing in-memory book operations with MongoDB soft delete functionality. The implementation now uses the new delete_book_by_id() helper function with find_one_and_update() to perform soft deletions.
- Introduces the
delete_book_by_id()helper function for MongoDB soft delete operations - Updates the DELETE endpoint to use MongoDB instead of in-memory data structures
- Adds comprehensive test coverage including edge cases and error handling
- Updates OpenAPI specification to reflect new error responses
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/datastore/mongo_helper.py | Adds new delete_book_by_id() function for MongoDB soft delete operations |
| app/routes.py | Updates DELETE endpoint to use MongoDB helper function with proper error handling |
| tests/test_mongo_helper.py | Adds comprehensive unit tests for the new MongoDB helper function |
| tests/test_app.py | Updates integration tests to work with MongoDB instead of in-memory data |
| tests/test_api_security.py | Updates security tests to work with the new MongoDB implementation |
| openapi.yml | Updates API documentation to include new 400 error response for invalid IDs |
Comments suppressed due to low confidence (1)
tests/test_mongo_helper.py:115
- Function name should be consistent with the actual function being tested. Consider renaming to 'test_delete_book_by_id_already_deleted_returns_none' to match the function name pattern used in other tests.
def test_soft_delete_already_deleted_book_returns_none():
|
|
||
| def delete_book_by_id(book_collection, book_id): | ||
| """ | ||
| Soft delete book with given id |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring should use proper capitalization and punctuation: 'Soft delete book with given ID.'
| Soft delete book with given id | |
| Soft delete a book with the given ID. |
Fix comment for clarity Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
Trello ticket: https://trello.com/c/O9jraVyM
This change finalizes the transition of the GET /books/{id} endpoint. The endpoint now uses the delete_book_by_id() helper function with find_one_and_update() to performa. soft delete.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests, manual testing, cURL, CI/CD pipeline
Checklist: