from fastapi.testclient import TestClient

from src.main import app


def test_get_ai_agent_report_live_delivery_approval_package_api():
    client = TestClient(app)
    response = client.get("/api/v1/agents/agent-report-live-delivery-approval-package")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_report_live_delivery_approval_package_v1"
    assert data["program_status"]["current_task_id"] == "P2-111"
    assert data["program_status"]["next_task_id"] == "P2-112"
    assert data["program_status"]["overall_completion_percent"] == 100
    assert data["prior_report_status_board"]["source_schema_version"] == "ai_agent_report_status_board_v1"
    assert data["prior_report_status_board"]["report_card_count"] == 3
    assert data["prior_report_status_board"]["work_units_total"] == 91
    assert data["prior_runtime_review"]["approval_package_schema_version"] == "ai_agent_runtime_readback_approval_package_v1"
    assert data["prior_runtime_review"]["implementation_review_schema_version"] == "ai_agent_runtime_readback_implementation_review_v1"
    assert data["delivery_approval_truth"]["delivery_approval_package_ready"] is True
    assert data["delivery_approval_truth"]["sre_war_room_route_locked"] is True
    assert data["delivery_approval_truth"]["payload_redaction_ready"] is True
    assert data["delivery_approval_truth"]["dry_run_receipt_ready"] is True
    assert data["delivery_approval_truth"]["scheduler_enabled"] is False
    assert data["delivery_approval_truth"]["gateway_queue_write_enabled"] is False
    assert data["delivery_approval_truth"]["telegram_send_enabled"] is False
    assert data["delivery_approval_truth"]["bot_api_call_enabled"] is False
    assert data["delivery_approval_truth"]["report_receipt_write_enabled"] is False
    assert data["delivery_approval_truth"]["ai_analysis_run_enabled"] is False
    assert data["delivery_approval_truth"]["scheduled_delivery_count_24h"] == 0
    assert data["delivery_approval_truth"]["telegram_send_count_24h"] == 0
    assert data["rollups"]["delivery_approval_packet_count"] == 5
    assert data["rollups"]["route_lock_gate_count"] == 4
    assert data["rollups"]["payload_redaction_check_count"] == 5
    assert data["rollups"]["dry_run_delivery_receipt_count"] == 4
    assert data["rollups"]["operator_action_count"] == 5
    assert data["rollups"]["approval_required_packet_count"] == 3
    assert data["rollups"]["blocked_packet_count"] == 1
    assert data["rollups"]["blocked_route_gate_count"] == 1
    assert data["rollups"]["blocked_receipt_count"] == 1
    assert data["rollups"]["owner_approval_received_count"] == 0
    assert data["rollups"]["scheduled_delivery_count"] == 0
    assert data["rollups"]["gateway_queue_write_count"] == 0
    assert data["rollups"]["telegram_send_count"] == 0
    assert data["rollups"]["bot_api_call_count"] == 0
    assert data["rollups"]["report_receipt_write_count"] == 0
    assert data["rollups"]["ai_analysis_run_count"] == 0
    assert data["rollups"]["auto_optimization_count"] == 0
    assert data["rollups"]["production_write_count"] == 0
