from fastapi.testclient import TestClient

from src.main import app


def test_get_ai_agent_operation_permission_model_api():
    client = TestClient(app)
    response = client.get("/api/v1/agents/agent-operation-permission-model")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_operation_permission_model_v1"
    assert data["program_status"]["current_task_id"] == "P2-101"
    assert data["program_status"]["next_task_id"] == "P2-102"
    assert data["program_status"]["overall_completion_percent"] == 97
    assert data["operation_permission_truth"]["permission_model_ready"] is True
    assert data["operation_permission_truth"]["runtime_execution_enabled"] is False
    assert data["operation_permission_truth"]["gateway_queue_write_enabled"] is False
    assert data["operation_permission_truth"]["telegram_send_enabled"] is False
    assert data["operation_permission_truth"]["telegram_bot_api_call_enabled"] is False
    assert data["operation_permission_truth"]["ai_runtime_worker_enabled"] is False
    assert data["operation_permission_truth"]["medium_low_auto_worker_enabled"] is False
    assert data["operation_permission_truth"]["production_write_enabled"] is False
    assert data["operation_permission_truth"]["secret_value_read_enabled"] is False
    assert data["operation_permission_truth"]["destructive_operation_enabled"] is False
    assert data["rollups"]["permission_lane_count"] == 5
    assert data["rollups"]["operation_category_count"] == 13
    assert data["rollups"]["human_approval_required_category_count"] == 4
    assert data["rollups"]["explicitly_blocked_category_count"] == 3
    assert data["rollups"]["agent_role_count"] == 3
    assert data["rollups"]["gate_transition_count"] == 8
    assert data["rollups"]["operator_decision_template_count"] == 5
    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
