diff --git a/apps/api/tests/test_ollama_auto_recovery.py b/apps/api/tests/test_ollama_auto_recovery.py index be2b1a29..94d8c799 100644 --- a/apps/api/tests/test_ollama_auto_recovery.py +++ b/apps/api/tests/test_ollama_auto_recovery.py @@ -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