Repository navigation
test(speech-engine): cover stream text extraction and websocket wrapping - #878
Open
aniruddhaadak80 wants to merge 1 commit into
Open
aniruddhaadak80 wants to merge 1 commit into
aniruddhaadak80 wants to merge 1 commit into
Conversation
Add regression coverage for two untested hand-maintained helpers (both under .fernignore): _extract_text in speech_engine/session.py across plain strings, OpenAI Responses/Chat Completions, Anthropic, and Gemini shapes (dict- and attribute-style chunks plus None/empty/mistyped edge cases), and wrap_websocket/_ASGIWebSocketAdapter in speech_engine/types.py (passthrough identity, ASGI delegation, TypeError).
PR SummaryLow Risk Overview The new suite pins It also covers Reviewed by Cursor Bugbot for commit 121f92a. Bugbot is set up for automated code reviews on this repo. Configure here. |
This was referenced Nov 9, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
New
tests/test_speech_engine_helpers.py(24 tests, no source changes) covering two hand-maintained Speech Engine helpers (both under.fernignore) that previously had zero direct coverage:_extract_text(speech_engine/session.py): plain-string passthrough,None/scalar/unknown shapes, and every documented provider format — OpenAI Responses (response.output_text.delta), OpenAI Chat Completions (choices[].delta.content), Anthropic (content_block_delta/text_delta), Gemini (candidates[].content.parts[].text) — each in dict- and attribute-style chunks, plus non-string/missing/empty edge cases.wrap_websocket/_ASGIWebSocketAdapter(speech_engine/types.py): websockets-style passthrough identity, ASGI-style wrapping,recv/send/closedelegation, andTypeErrorfor unknown styles.Why
send_response()auto-detects LLM stream formats via_extract_text, so a provider-side field change that breaks extraction silently drops response text; FastAPI/Starlette integration depends on the adapter delegating correctly. Pinning both behaviors with unit tests (no network, no credentials) locks them against regressions. Follows the repo's test-only precedent (#850, #827).How tested
pytest tests/test_speech_engine_helpers.py: 24/24 pass.pytest tests/: 223 passed; the only 16 failures are pre-existing live-API tests (test_tts,test_stt,test_voices, …) failing with401 needs_authorizationbecause noELEVENLABS_API_KEYis set locally — CI provides it as a secret. Untouched by this PR (new file only).ruff checkclean on the new file.