fix(test): repair 6 failing tests blocking develop CI - #19
Merged
Conversation
Two unrelated groups, both pre-existing on develop: 1. tests/unit/core/test_inject_llm_provider.py (3 failures) Tests pass llm_provider="openai"/"anthropic" (string) which eagerly builds a real provider requiring OPENAI_API_KEY/ANTHROPIC_API_KEY. They only check identity wiring and never call the LLM. Add an autouse fixture that supplies dummy env keys so construction succeeds offline. 2. tests/unit/test_llm_providers.py::TestOpenAIReasoningTokens (3 failures) Thinking models (gpt-5*) route through the Responses API since #9/#15, but these tests still mocked client.chat.completions.create — so the awaited call hit an un-mocked MagicMock ("can't be awaited"). Rewrite to mock client.responses.create with a Responses-API-shaped response (output items + usage.output_tokens_details.reasoning_tokens) via a shared helper.
3 tasks
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.
Problem
developCI is red — 6 unit tests fail (the same 6 that fail on PR #18 develop→stable, since #18's head is develop). Develop has been broken since #16 (inject LLMProvider) and the Responses API work (#9/#15) landed.Root causes & fixes
1.
test_inject_llm_provider.py(3 failures) — tests construct resources withllm_provider="openai"/"anthropic"(string path), which builds a real provider that readsOPENAI_API_KEY/ANTHROPIC_API_KEYfrom env. They only assert identity wiring and never call the LLM.→ Added an autouse fixture supplying dummy env keys so construction succeeds offline.
2.
TestOpenAIReasoningTokens(3 failures) — thinking models (gpt-5*) now route through the Responses API (client.responses.create) per #9/#15, but these tests still mockedclient.chat.completions.create. The awaitedresponses.createhit an un-mockedMagicMock.→ Rewrote the 3 tests to mock
client.responses.createwith a Responses-API-shaped response (outputitems +usage.output_tokens_details.reasoning_tokens) via a shared_responses_api_responsehelper. Test intent preserved: verify reasoning-token parsing (150 → 150, absent → None, 0 → None via falsy coercion).Verification
Full suite, CI-identical invocation (
DANA_MOCK_LLM=true DANA_USE_REAL_LLM=false uv run pytest tests/ -m "not live and not deep"):Ruff + format clean on both files.
Scope
Test-only change. No production code touched.