From d5a1875c9eeb70c5533d3cafc9a45ee84fc8e5e3 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Wed, 24 Jun 2026 21:18:40 -0700 Subject: [PATCH] [eric] tests: streaming harness configures a provider so the real loop resolves cleanly --- backend/tests/test_streaming_harness.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backend/tests/test_streaming_harness.py b/backend/tests/test_streaming_harness.py index 9974b37b..7e6401ef 100644 --- a/backend/tests/test_streaming_harness.py +++ b/backend/tests/test_streaming_harness.py @@ -6,6 +6,7 @@ tool calls are recorded, and the turn completes.""" import asyncio +import pytest import claude_agent_sdk from claude_agent_sdk import AssistantMessage, ResultMessage from claude_agent_sdk.types import TextBlock, ToolUseBlock, ThinkingBlock, StreamEvent @@ -14,6 +15,21 @@ from backend.apps.agents.agent_manager import AgentManager import backend.apps.agents.core.ws_manager as ws_mod +@pytest.fixture(autouse=True) +def p_provider_configured(monkeypatch): + """Every harness test drives the REAL loop, which resolves a provider before it queries. + Hand it a direct anthropic key so resolution succeeds, instead of leaning on a key leaking + in from the dev machine's settings (which made these tests pass by accident and fail in a + clean checkout). The harness tests the streaming loop, not provider config.""" + import backend.apps.agents.agent_manager as am + import backend.apps.agents.manager.run.RunOptionsMixin as run_opts + from backend.apps.settings.models import AppSettings + settings = AppSettings(connection_mode="own_key", anthropic_api_key="sk-ant-test") + monkeypatch.setattr(am, "load_settings", lambda: settings, raising=True) + monkeypatch.setattr(run_opts, "load_settings", lambda: settings, raising=True) + yield + + def p_stream(event): return StreamEvent(uuid="u", session_id="sdk-1", event=event)