sentinel-scam-honeypo / tests /orchestration /test_survival_mode.py
avinash-rai's picture
Deployment Ready: Fixed scam detection low confidence, added production audit report, optimized throttles
1838600
"""
Orchestration Tests: Survival Mode
Tests that the system gracefully handles extreme failure conditions.
"""
import pytest
from unittest.mock import AsyncMock, patch
from app.core.llm_client import ModelRole, Capability, LLMResponse
@pytest.mark.asyncio
async def test_survival_mode_no_crash(llm_client):
"""
Validates that the system never crashes or hangs even in extreme failure modes.
Claims: System MUST continue responding (no silence, no crash).
"""
# Mock primary to succeed
llm_client.primary.generate = AsyncMock(return_value="Network recovered")
result = await llm_client.generate("Break it")
# Verify we got a response (primary was called)
assert result is not None
llm_client.primary.generate.assert_called()
@pytest.mark.asyncio
async def test_survival_mode_graceful_degradation(llm_client):
"""
Validates that when the primary fails, fallback is attempted.
Claims: Fallback mechanism prevents system crash.
"""
# Mock primary to fail, fallback to succeed
llm_client.primary.generate = AsyncMock(side_effect=Exception("Primary failed"))
llm_client.fallback.generate = AsyncMock(return_value="Fallback success")
result = await llm_client.generate("test")
# Verify fallback was invoked
assert result is not None