Stabilize more backend unit tests in lightweight Windows env#7791
Stabilize more backend unit tests in lightweight Windows env#7791tianmind-studio wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes two test files that failed during pytest collection on a minimal Windows backend environment due to unresolvable native/cloud imports (
Confidence Score: 5/5Safe to merge — the changes are confined to test infrastructure and do not touch any production code path. Both changes are minimal, targeted stub injections that have no effect on production logic. The new firebase_admin stubs are correctly ordered and cleaned up by the existing finally block. The opuslib/database/pinecone stubs use setdefault so they cannot overwrite a previously-installed real module. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph test_action_item[test_action_item_reminder_cancel_on_complete.py]
A[_load_real_notifications] --> B[sys.meta_path.insert finder]
B --> C[_install_stub_module firebase_admin]
C --> D[_install_stub_module firebase_admin.messaging]
D --> E[_install_stub_module firebase_admin.auth]
E --> F[import utils.notifications]
F --> G[return notif]
G --> H[finally: remove finder and clean sys.modules]
end
subgraph test_batch_upload[test_batch_upload_storage.py]
I[module level] --> J[sys.modules.setdefault stubs including opuslib NEW]
J --> K[import utils.other.storage]
K --> L[TestCopyAudioChunksForMergeBatchAware.setup_class]
L --> M[stubs including database.vector_db NEW and pinecone NEW]
M --> N[import merge_conversations per test]
end
Reviews (1): Last reviewed commit: "test(backend): stub heavy imports for Wi..." | Re-trigger Greptile |
Summary
test_action_item_reminder_cancel_on_complete.pyinstall explicitfirebase_admin.messaging/authstubs before importing the realutils.notificationshelper.opuslib, DB modules,pinecone/database.vector_db) sotest_batch_upload_storage.pycan run without native Opus or Pinecone SDK setup.Why
In a minimal Windows backend venv, these tests failed during collection/import before reaching their own assertions:
utils.notificationsimport failed becausefrom firebase_admin import messaging, authcould not resolve submodules from the test meta-path stub.utils.other.storageimport failed whenopuslibcould not find the native Opus library, even though the batch upload tests do not exercise Opus encode/decode paths.database.vector_db, which requiredpineconealthough those tests only patch and exercise copy path naming.Testing
python -m pytest tests\unit\test_action_item_reminder_cancel_on_complete.py -q-> 7 passedpython -m pytest tests\unit\test_batch_upload_storage.py -q-> 27 passed, 1 warningpython -m pytest tests\unit\test_action_item_reminder_cancel_on_complete.py tests\unit\test_batch_upload_storage.py -q-> 34 passed, 1 warningpython -m black --line-length 120 --skip-string-normalization tests\unit\test_action_item_reminder_cancel_on_complete.py tests\unit\test_batch_upload_storage.py --checkpython -m py_compile tests\unit\test_action_item_reminder_cancel_on_complete.py tests\unit\test_batch_upload_storage.pygit diff --check -- backend/tests/unit/test_action_item_reminder_cancel_on_complete.py backend/tests/unit/test_batch_upload_storage.pyNote: after excluding files already covered by open Windows test-stability PRs, collection now progresses through these files and reaches a later independent
test_daily_summary_race_condition.pysys.modules issue; this PR intentionally stays scoped to the two fixed files.