[V10.327] 補 OpenClaw 備援可觀測性
All checks were successful
CD Pipeline / deploy (push) Successful in 1m28s
All checks were successful
CD Pipeline / deploy (push) Successful in 1m28s
This commit is contained in:
@@ -28,6 +28,12 @@ def test_registry_contains_core_callers():
|
||||
'openclaw_daily', 'openclaw_weekly', 'openclaw_monthly',
|
||||
'openclaw_meta', 'openclaw_qa',
|
||||
'openclaw_qa_gemini_fallback', 'openclaw_qa_nim',
|
||||
'openclaw_daily_gemini_fallback', 'openclaw_weekly_gemini_fallback',
|
||||
'openclaw_monthly_gemini_fallback', 'openclaw_meta_gemini_fallback',
|
||||
'openclaw_daily_insight_gemini_fallback',
|
||||
'openclaw_daily_nim', 'openclaw_weekly_nim',
|
||||
'openclaw_monthly_nim', 'openclaw_meta_nim',
|
||||
'openclaw_daily_insight_nim',
|
||||
# MCP
|
||||
'mcp_l1_grounding', 'mcp_collector',
|
||||
# Code Review
|
||||
|
||||
38
tests/test_mcp_collector_ollama_first.py
Normal file
38
tests/test_mcp_collector_ollama_first.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
|
||||
def test_mcp_collector_uses_ollama_before_gemini(monkeypatch):
|
||||
import services.mcp_collector_service as mcp_mod
|
||||
import services.mcp_router as router_mod
|
||||
|
||||
service = mcp_mod.MCPCollectorService()
|
||||
monkeypatch.setattr(service, "_read_cache", lambda _topic: None)
|
||||
monkeypatch.setattr(router_mod, "is_mcp_router_enabled", lambda: False)
|
||||
monkeypatch.setattr(mcp_mod, "_OLLAMA_AVAILABLE", True)
|
||||
|
||||
def fail_gemini_init():
|
||||
raise AssertionError("Gemini must not initialize before Ollama fallback is tried")
|
||||
|
||||
calls = []
|
||||
|
||||
class FakeOllamaService:
|
||||
def __init__(self, model=None):
|
||||
self.model = model
|
||||
|
||||
def generate(self, **kwargs):
|
||||
calls.append(kwargs)
|
||||
return SimpleNamespace(
|
||||
success=True,
|
||||
content="(此為基於歷史趨勢的預測性洞察) 台灣電商促銷可先檢查母親節、618 與競品價差。",
|
||||
error=None,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(service, "_ensure_init", fail_gemini_init)
|
||||
monkeypatch.setattr(mcp_mod, "OllamaService", FakeOllamaService)
|
||||
|
||||
result = service._search_topic("market_trends", "台灣電商促銷趨勢")
|
||||
|
||||
assert "基於歷史趨勢" in result
|
||||
assert calls
|
||||
assert calls[0]["model"]
|
||||
assert calls[0]["options"]["num_predict"] == 800
|
||||
Reference in New Issue
Block a user