test(DATAGO-129265): Migrate repository unit tests to real DB integration tests #2#1274
test(DATAGO-129265): Migrate repository unit tests to real DB integration tests #2#1274dylanwalsh-solace wants to merge 3 commits intomainfrom
Conversation
✅ FOSSA Guard: Licensing (
|
✅ FOSSA Guard: Vulnerability (
|
60f3218 to
bd6f3e5
Compare
05d1d39 to
95bf350
Compare
95bf350 to
ed44965
Compare
…to real database integration tests
35602c2 to
7e3ba06
Compare
There was a problem hiding this comment.
Pull request overview
This PR continues the test-infrastructure migration away from fragile internal DB/repository mocking toward real database-backed integration tests, while also tightening some unit-test assertions to check outcomes/parameters rather than only mock interactions.
Changes:
- Replaced mocked repository/unit tests with new integration tests that exercise real SQLite/PostgreSQL persistence for task repository, session move, task logger, and SSE buffer behavior.
- Improved share-service/share-access unit test assertions to validate returned values and key call parameters rather than only “called once” checks.
- Updated embed template-resolution unit tests to use
sam_test_infrastructure’s in-memory artifact service.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/services/test_session_service_move_to_project.py | Deleted mocked unit tests in favor of DB integration coverage. |
| tests/unit/gateway/http_sse/test_share_service_behaviours.py | Assertion refactors around snapshot updates and formatting changes. |
| tests/unit/gateway/http_sse/test_share_access_control.py | Assertion refactors for access control behaviors and router-level status mapping. |
| tests/unit/gateway/http_sse/repository/test_task_repository.py | Deleted mocked SQLAlchemy-chain unit tests replaced by DB integration tests. |
| tests/unit/common/utils/embeds/test_automatic_template_resolution.py | Switched to sam_test_infrastructure artifact service import and formatting tweaks. |
| tests/integration/apis/persistence/tasks/test_task_repository_active_children.py | New DB integration coverage for TaskRepository.find_active_children() (NULL status + recursion). |
| tests/integration/apis/persistence/tasks/test_task_logger_service_integration.py | New DB integration coverage for _save_chat_messages_for_background_task() persistence. |
| tests/integration/apis/persistence/sse_buffer/test_sse_buffer_integration.py | New DB integration coverage for persistent SSE buffering (normal + hybrid). |
| tests/integration/apis/persistence/sessions/test_session_service_integration.py | New DB integration coverage for move_session_to_project() persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|





What is the purpose of this change?
DATAGO-129265 - Change included as part of a larger audit to improve testing across the community repo.
This PR addresses internal mocking issues identified in the test infrastructure audit. It migrates tests that were mocking internal repository/database operations to use real database integration tests, and improves assertion quality by verifying actual outcomes instead of mock interactions.
How was this change implemented?
Migrated to Integration Tests (New Files):
test_task_repository_active_children.py- Replaces unit tests that mocked SQLAlchemy query chains. Now testsfind_active_children()against real SQLite/PostgreSQL databases, properly verifying SQL NULL handling for active child tasks.test_session_service_integration.py- Replaces unit tests that mocked DB operations. Now testsmove_session_to_project()with real database, verifying session.project_id updates persist correctly.test_task_logger_service_integration.py- Companion integration tests for TaskLoggerService's_save_chat_messages_for_background_task()method. Verifies task events are correctly reconstructed and saved to chat_tasks table.test_sse_buffer_integration.py- Companion integration tests for PersistentSSEEventBuffer. Verifies event buffering, flushing, and cleanup operations against real database (both normal and hybrid modes).Assertion Improvements (Modified Files):
test_share_service_behaviours.py- Replacedrepository.update_user_snapshot_time.assert_called_once()with actual verification that the returned timestamp is valid and repository was called with correct parameters.test_share_access_control.py- Improved assertions to verify actual state changes rather than just mock interactions.Deleted Files:
tests/unit/gateway/http_sse/repository/test_task_repository.py- Fully replaced by integration teststests/unit/services/test_session_service_move_to_project.py- Fully replaced by integration testsAll new integration tests use the existing DatabaseProvider infrastructure with SQLite and PostgreSQL test containers (via pytest parametrization).
Key Design Decisions (optional - delete if not applicable)
How was this change tested?
Is there anything the reviewers should focus on/be aware of?