fix(test): 更新 auto_recovery 測試斷言至 ADR-110(ollama_111 → ollama_gcp_a)
- notify_recovery 斷言改為 "ollama_gcp_a"(3 處) - alert_recovery payload["to"] 改為 "ollama" - test_full_recovery_flow 改用 mock alerter 避免打真實 Telegram Bot API Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -222,7 +222,11 @@ class TestDebounce:
|
||||
"""
|
||||
完整場景:OFFLINE → HEALTHY × 3 → 觸發 switch_back
|
||||
"""
|
||||
svc, mock_monitor, mock_failover = _make_service(current_primary="gemini", stable_count=3)
|
||||
mock_alerter = AsyncMock()
|
||||
mock_alerter.alert_recovery = AsyncMock()
|
||||
svc, mock_monitor, mock_failover = _make_service(
|
||||
current_primary="gemini", stable_count=3, alerter=mock_alerter
|
||||
)
|
||||
mock_monitor.check.side_effect = [
|
||||
_make_health(HealthStatus.HEALTHY),
|
||||
_make_health(HealthStatus.HEALTHY),
|
||||
@@ -235,7 +239,8 @@ class TestDebounce:
|
||||
# 觸發後 current_primary 應切回 ollama
|
||||
assert svc.current_primary == "ollama"
|
||||
mock_failover.clear_cache.assert_awaited_once()
|
||||
mock_failover.notify_recovery.assert_called_once_with("ollama_111")
|
||||
# 2026-05-03 ogt: ADR-110 — notify_recovery 改為 "ollama_gcp_a"(GCP-A Primary)
|
||||
mock_failover.notify_recovery.assert_called_once_with("ollama_gcp_a")
|
||||
|
||||
|
||||
# =============================================================================
|
||||
@@ -262,7 +267,8 @@ class TestSwitchBackToOllama:
|
||||
async def test_calls_notify_recovery(self):
|
||||
svc, _, mock_failover = _make_service(current_primary="gemini")
|
||||
await svc._switch_back_to_ollama()
|
||||
mock_failover.notify_recovery.assert_called_once_with("ollama_111")
|
||||
# 2026-05-03 ogt: ADR-110 — notify_recovery 改為 "ollama_gcp_a"(GCP-A Primary)
|
||||
mock_failover.notify_recovery.assert_called_once_with("ollama_gcp_a")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calls_telegram_alerter_when_set(self):
|
||||
@@ -277,7 +283,7 @@ class TestSwitchBackToOllama:
|
||||
mock_alerter.alert_recovery.assert_awaited_once()
|
||||
payload = mock_alerter.alert_recovery.call_args[0][0]
|
||||
assert payload["from"] == "gemini"
|
||||
assert payload["to"] == "ollama_111"
|
||||
assert payload["to"] == "ollama" # 2026-05-03 ogt: ADR-110 — "to" 改為 "ollama"(不再指定 111)
|
||||
assert payload["stable_count"] == 3
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user