omi icon indicating copy to clipboard operation
omi copied to clipboard

Stabilize sync transcription preference tests on Windows

Open tianmind-studio opened this issue 5 months ago • 1 comments

Summary

  • Stub import-time SDK/native audio dependencies in test_sync_transcription_prefs.py so the sync router tests run in lightweight Windows environments without Deepgram or a system Opus library.
  • Update the tests to patch the current routers.sync symbols (prerecorded, httpx.get, and submit_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, system opus) during import, plus stale patch targets from older routers.sync call sites

Testing

  • python -m pytest tests\unit\test_sync_transcription_prefs.py -q -> 61 passed, 2 warnings
  • python -m black --line-length 120 --skip-string-normalization tests\unit\test_sync_transcription_prefs.py --check
  • python -m py_compile tests\unit\test_sync_transcription_prefs.py
  • git diff --check origin/main...HEAD

tianmind-studio avatar Jun 10 '26 08:06 tianmind-studio

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.modules stubs for dependencies unavailable on Windows (no system Opus library, no Deepgram SDK), using both real logic (cosine similarity for _compare_embeddings) and MagicMock sentinels where behaviour doesn't matter.
  • Patch target corrections: All deepgram_prerecorded patches are updated to routers.sync.prerecorded, and requests patches to routers.sync.httpx, aligning with the current production import names.
  • Assertion updates: Model-selection assertions (model == 'nova-3') are replaced with return_language is True to 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

greptile-apps avatar Jun 10 '26 08:06 greptile-apps