from fastapi.testclient import TestClient

from src.main import app


def test_get_ai_agent_report_runtime_readiness_api():
    client = TestClient(app)
    response = client.get("/api/v1/agents/agent-report-runtime-readiness")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_report_runtime_readiness_v1"
    assert data["program_status"]["current_task_id"] == "P2-403L"
    assert data["program_status"]["next_task_id"] == "P2-403M"
    assert data["program_status"]["overall_completion_percent"] == 86
    assert data["activation_truth"]["report_scheduler_contract_ready"] is True
    assert data["activation_truth"]["telegram_gateway_queue_contract_ready"] is True
    assert data["activation_truth"]["live_report_delivery_enabled"] is False
    assert data["activation_truth"]["telegram_gateway_queue_write_enabled"] is False
    assert data["activation_truth"]["medium_low_auto_worker_enabled"] is False
    assert data["activation_truth"]["production_optimization_count_24h"] == 0
    assert data["telegram_route_readiness"]["canonical_room"] == "AwoooI SRE 戰情室"
    assert data["telegram_route_readiness"]["direct_bot_api_allowed"] is False
    assert data["telegram_route_readiness"]["bot_log_out_allowed"] is False
    assert data["rollups"]["runtime_lane_count"] == 7
    assert data["rollups"]["operator_decision_count"] == 7
    assert data["rollups"]["current_enabled_count"] == 0
    assert data["rollups"]["live_report_delivery_count"] == 0
    assert data["rollups"]["telegram_gateway_queue_write_count"] == 0
    assert data["rollups"]["live_medium_low_auto_execution_count"] == 0
