"""Tests for the /health and /ready endpoints."""

from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

from llmhosts import __version__

if TYPE_CHECKING:
    from httpx import AsyncClient

# -------------------------------------------------------------------
# /health
# -------------------------------------------------------------------


@pytest.mark.unit
async def test_health_returns_200(client: AsyncClient) -> None:
    resp = await client.get("/health")
    assert resp.status_code == 200


@pytest.mark.unit
async def test_health_contains_status(client: AsyncClient) -> None:
    data = (await client.get("/health")).json()
    assert data["status"] == "ok"


@pytest.mark.unit
async def test_health_contains_version(client: AsyncClient) -> None:
    data = (await client.get("/health")).json()
    assert data["version"] == __version__


@pytest.mark.unit
async def test_health_contains_timestamp(client: AsyncClient) -> None:
    data = (await client.get("/health")).json()
    assert isinstance(data["timestamp"], int)
    assert data["timestamp"] > 0


# -------------------------------------------------------------------
# /ready
# -------------------------------------------------------------------


@pytest.mark.unit
async def test_ready_returns_200(client: AsyncClient) -> None:
    resp = await client.get("/ready")
    assert resp.status_code == 200


@pytest.mark.unit
async def test_ready_contains_status(client: AsyncClient) -> None:
    data = (await client.get("/ready")).json()
    assert data["status"] == "ready"


@pytest.mark.unit
async def test_ready_contains_version(client: AsyncClient) -> None:
    data = (await client.get("/ready")).json()
    assert data["version"] == __version__
