mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-11 20:27:44 +02:00
[eric] agents: pin gemini + openrouter env-route branches (5 provider routes now covered)
This commit is contained in:
@@ -110,6 +110,31 @@ def test_loop_builds_direct_openai_key_env(monkeypatch):
|
||||
assert "openai-passthrough" in env["OPENAI_BASE_URL"]
|
||||
|
||||
|
||||
def test_loop_builds_direct_gemini_key_env(monkeypatch):
|
||||
# Direct Google AI Studio key: routed through the local anthropic-proxy that scrubs the
|
||||
# JSON-Schema fields Gemini rejects. Pin the Gemini keys + the proxy base url.
|
||||
from backend.apps.settings.models import AppSettings
|
||||
settings = AppSettings(google_api_key="g-key-test")
|
||||
env = _capture_env(monkeypatch, settings, "gemini", "cp-gemini/gemini-2.5-pro",
|
||||
{"route": "api", "api": "gemini"})
|
||||
assert env["GEMINI_API_KEY"] == "g-key-test"
|
||||
assert env["GOOGLE_API_KEY"] == "g-key-test"
|
||||
assert "anthropic-proxy" in env["ANTHROPIC_BASE_URL"]
|
||||
|
||||
|
||||
def test_loop_builds_openrouter_env(monkeypatch):
|
||||
# OpenRouter: routes through 9Router (must be up). Pin the 9Router base + that subagent ids
|
||||
# fall back to OR's resold Claude when the user has no Anthropic key.
|
||||
from backend.apps.settings.models import AppSettings
|
||||
import backend.apps.nine_router as nr
|
||||
monkeypatch.setattr(nr, "is_running", lambda: True, raising=True)
|
||||
settings = AppSettings(openrouter_api_key="or-key-test")
|
||||
env = _capture_env(monkeypatch, settings, "openrouter", "openrouter/anthropic/claude-sonnet-4.5", None)
|
||||
assert env["ANTHROPIC_API_KEY"] == "9router"
|
||||
assert env["ANTHROPIC_BASE_URL"] == "http://localhost:20128"
|
||||
assert env["CLAUDE_CODE_SUBAGENT_MODEL"] == "openrouter/anthropic/claude-sonnet-4.5"
|
||||
|
||||
|
||||
def test_loop_builds_direct_anthropic_key_env(monkeypatch):
|
||||
# Pin the provider env/route config the loop builds, the part the hook flagged as untested.
|
||||
# Drive the REAL loop with a direct-Anthropic-key config (own_key, a non-9router model, no
|
||||
|
||||
Reference in New Issue
Block a user