Stabilize sync transcription preference tests on Windows
Summary
- Stub import-time SDK/native audio dependencies in
test_sync_transcription_prefs.pyso the sync router tests run in lightweight Windows environments without Deepgram or a system Opus library. - Update the tests to patch the current
routers.syncsymbols (prerecorded,httpx.get, andsubmit_with_context) instead of stale call sites. - Keep speaker-ID and transcription-preference assertions focused on the router behavior under test; production code is unchanged.
Windows reproduction
Before this change on this Windows test environment:
python -m pytest tests\unit\test_sync_transcription_prefs.py -q->61 failed, 1 warning- failures were dominated by missing optional/native dependencies (
deepgram, systemopus) during import, plus stale patch targets from olderrouters.synccall sites
Testing
python -m pytest tests\unit\test_sync_transcription_prefs.py -q->61 passed, 2 warningspython -m black --line-length 120 --skip-string-normalization tests\unit\test_sync_transcription_prefs.py --checkpython -m py_compile tests\unit\test_sync_transcription_prefs.pygit diff --check origin/main...HEAD
Greptile Summary
This PR fixes 61 failing tests in test_sync_transcription_prefs.py on Windows by stubbing optional native dependencies (opuslib, deepgram, pydub, vad, speaker-embedding modules) at import time, and updating stale patch targets to match the current routers.sync symbols.
- Stub layer: Adds module-level
sys.modulesstubs for dependencies unavailable on Windows (no system Opus library, no Deepgram SDK), using both real logic (cosine similarity for_compare_embeddings) andMagicMocksentinels where behaviour doesn't matter. - Patch target corrections: All
deepgram_prerecordedpatches are updated torouters.sync.prerecorded, andrequestspatches torouters.sync.httpx, aligning with the current production import names. - Assertion updates: Model-selection assertions (
model == 'nova-3') are replaced withreturn_language is Trueto reflect the current router contract;@patch('routers.sync.submit_with_context', MagicMock())is added to three classes that call background-task submission.
Confidence Score: 4/5
Test-only change; production code is untouched and the updated patch targets correctly reflect the current routers.sync imports.
The patch-target and assertion updates are accurate (verified against routers/sync.py imports). The two concerns — _compare_embeddings shape assumption and opuslib's direct sys.modules assignment — are unlikely to cause failures in the current test suite but could bite future contributors adding 1D-embedding tests or running the file alongside tests that expect a real opuslib installation.
backend/tests/unit/test_sync_transcription_prefs.py — the stub setup block (lines 80–127) warrants a second look for the opuslib assignment style and the embedding shape assumption.
Important Files Changed
| Filename | Overview |
|---|---|
| backend/tests/unit/test_sync_transcription_prefs.py | Adds Windows-compatible stubs for opuslib/deepgram/pydub/vad/speaker-embedding, updates patch targets from stale deepgram_prerecorded/requests to the current prerecorded/httpx symbols, and replaces model assertions with return_language assertions. Two minor concerns: _compare_embeddings assumes 2D array shape, and opuslib uses direct sys.modules assignment rather than setdefault. |
Reviews (1): Last reviewed commit: "Stabilize sync transcription prefs tests..." | Re-trigger Greptile