Skip to content

Conversation

@ChingEnLin
Copy link
Owner

This pull request introduces improvements to the testing setup and modifies the way documents are updated in the database. The most significant change is switching from a partial update to a full document replacement, ensuring that fields removed from the input are also removed from the stored document.

Testing enhancements:

  • Added mongomock, pytest-mock, and freezegun to backend/requirements.txt to support more robust and isolated testing, especially for mocking MongoDB and time-dependent code.

Database update logic:

  • Updated the update_document function in backend/services/data_documents_service.py to use replace_one instead of update_one, ensuring that the entire document is replaced and deleted fields are removed from the database, not just overwritten.

Copilot AI review requested due to automatic review settings September 1, 2025 13:09

This comment was marked as outdated.

@ChingEnLin ChingEnLin requested a review from Copilot September 1, 2025 13:15
Copy link
Contributor

Copilot AI left a 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 pull request introduces improvements to the testing setup and modifies the way documents are updated in the database. The change switches from a partial update to a full document replacement, ensuring that fields removed from the input are also removed from the stored document.

  • Enhanced testing setup with comprehensive MongoDB operation testing using mongomock
  • Switched update operation from update_one to replace_one for complete document replacement
  • Added improved timestamp handling that preserves creation date while updating modification date

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
backend/tests/test_mongo_operations.py Adds comprehensive test suite for MongoDB operations using mongomock for isolation
backend/services/data_documents_service.py Updates document update logic to use replace_one instead of update_one
backend/requirements.txt Adds testing dependencies: mongomock, pytest-mock, and freezegun

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ChingEnLin ChingEnLin merged commit 6e5740d into dev Sep 1, 2025
3 checks passed
@ChingEnLin ChingEnLin deleted the fix/update_doc branch September 1, 2025 13:23
@github-actions
Copy link

github-actions bot commented Sep 1, 2025

🎉 This PR is included in version 2.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants