from fastapi.testclient import TestClient

from src.main import app


def test_get_ai_agent_candidate_operation_dry_run_evidence_api():
    client = TestClient(app)
    response = client.get("/api/v1/agents/agent-candidate-operation-dry-run-evidence")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_candidate_operation_dry_run_evidence_v1"
    assert data["program_status"]["current_task_id"] == "P2-102"
    assert data["program_status"]["next_task_id"] == "P2-103"
    assert data["program_status"]["overall_completion_percent"] == 98
    assert data["dry_run_truth"]["dry_run_evidence_gate_ready"] is True
    assert data["dry_run_truth"]["all_candidate_operations_have_dry_run_evidence"] is True
    assert data["dry_run_truth"]["runtime_execution_enabled"] is False
    assert data["dry_run_truth"]["gateway_queue_write_enabled"] is False
    assert data["dry_run_truth"]["telegram_send_enabled"] is False
    assert data["dry_run_truth"]["telegram_bot_api_call_enabled"] is False
    assert data["dry_run_truth"]["production_write_enabled"] is False
    assert data["dry_run_truth"]["secret_value_read_enabled"] is False
    assert data["dry_run_truth"]["destructive_operation_enabled"] is False
    assert data["rollups"]["candidate_operation_count"] == 13
    assert data["rollups"]["candidate_with_dry_run_evidence_count"] == 13
    assert data["rollups"]["passed_no_write_count"] == 4
    assert data["rollups"]["needs_owner_review_count"] == 3
    assert data["rollups"]["blocked_until_allowlist_count"] == 2
    assert data["rollups"]["blocked_by_policy_count"] == 4
    assert data["rollups"]["verifier_plan_count"] == 6
    assert data["rollups"]["gate_evidence_requirement_count"] == 7
    assert data["rollups"]["operator_handoff_count"] == 5
    assert data["rollups"]["side_effect_count"] == 0
    assert data["rollups"]["runtime_execution_count"] == 0
    assert data["rollups"]["gateway_queue_write_count"] == 0
    assert data["rollups"]["telegram_send_count"] == 0
    assert data["rollups"]["production_write_count"] == 0
    assert data["rollups"]["secret_value_read_count"] == 0
    assert data["rollups"]["destructive_operation_count"] == 0
