"""Health endpoint tests."""

from __future__ import annotations

from fastapi import FastAPI
from fastapi.testclient import TestClient

from app.api.routes import health as health_routes


def test_health_includes_ai_provider_status(monkeypatch) -> None:
    """Health response should include selected AI provider availability."""
    monkeypatch.setattr(
        health_routes.ai_provider_registry,
        "selected_provider_health",
        lambda: {"selected": "ollama", "available": False},
    )

    app = FastAPI()
    app.include_router(health_routes.router)
    with TestClient(app) as client:
        response = client.get("/health")

    assert response.status_code == 200
    payload = response.json()
    assert payload["status"] == "ok"
    assert payload["language"] in {"es", "en"}
    assert payload["ai_provider"]["selected"] == "ollama"
    assert payload["ai_provider"]["available"] is False
