test: fix tests broken by PR #2918 SDK abstraction + add Copilot routing unit tests#2920
Merged
rysweet merged 1 commit intofeat/2917-power-steering-sdk-abstractionfrom Mar 7, 2026
Conversation
…ing unit tests PR #2918 replaced `from claude_agent_sdk import query` with `from power_steering_sdk import query_llm`, removing `query` as a module-level attribute from `claude_power_steering`. This broke two test files that patched the now-removed attribute. Fixes: - test_power_steering_shutdown.py: remove stale @patch("claude_power_steering.query") decorator and unused mock_query param from test_no_timing_regression (test only calls is_shutting_down() which needs no SDK mock) - test_issue_1872_bug_fixes.py: update 8 tests to patch `claude_power_steering.query_llm` (AsyncMock returning str) instead of the removed `claude_power_steering.query` (generator yielding MockMessage) Bug fixes: - power_steering_sdk.py (both copies): fix _detector_cache type annotation from `object | None` to `str | None` and remove the # type: ignore[return-value] comment that worked around the self-inflicted mismatch New tests: - tests/test_power_steering_sdk.py: 21 mock-based unit tests covering _query_copilot async lifecycle (start/create_session/send_and_wait/stop), event.data.content text extraction, query_llm routing to Copilot/Claude, fallback behavior, SDK_AVAILABLE flag, and _query_claude text extraction All 68 tests across test_power_steering_sdk, test_sdk_integration, test_copilot_e2e_power_steering, and test_power_steering_shutdown pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Repo Guardian - PassedAll files in this PR are legitimate production code and tests. No ephemeral content detected. Files analyzed:
All files are durable, reusable components that belong in the repository.
|
e9fa347
into
feat/2917-power-steering-sdk-abstraction
18 checks passed
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.
Summary
Validation of PR #2918 (feat: power-steering SDK abstraction). Found and fixed test regressions introduced by the
query→query_llmAPI change, added comprehensive mock-based unit tests for the new Copilot routing, and confirmed philosophy compliance.Changes
Test Fixes (broken by PR #2918)
test_power_steering_shutdown.py: Remove stale
@patch("claude_power_steering.query")decorator fromtest_no_timing_regression_during_normal_operation. The test only callsis_shutting_down()— no SDK mock needed.test_issue_1872_bug_fixes.py: Update 8 tests to patch
claude_power_steering.query_llm(AsyncMock returningstr) instead of the removedclaude_power_steering.query. Also updatecall_args[1]["prompt"]→call_args[0][0]for positional arg access.Type Fix (philosophy compliance)
_detector_cachetype annotation fromobject | Nonetostr | Noneand remove the# type: ignore[return-value]workaround.New Mock-Based Unit Tests
_query_copilotasync lifecycle:await client.start(),create_session(),send_and_wait(),stop()all awaitedclient.stop()called even whensend_and_waitraises (finally block)stop()exceptions suppressedevent.data.content(and None/missing data cases)query_llmrouting: copilot launcher → Copilot SDK, claude launcher → Claude SDK""SDK_AVAILABLEexported,query_llmin__all___query_claudetext extraction from content blocks and string contentPhilosophy Compliance
power_steering_sdk.py: MINOR_ISSUES / Overall COMPLIANTsys.path.insertcoupling in_detect_launcheris fragile but protected by broad exceptTest Results
All 68 key tests pass:
Validates all PR #2918 success criteria.
🤖 Generated with Claude Code