"""Tests for /api/v1/health."""

from __future__ import annotations

import pytest
from httpx import ASGITransport, AsyncClient

from app.main import app


@pytest.mark.asyncio
async def test_health_returns_ok() -> None:
    transport = ASGITransport(app=app)
    async with AsyncClient(transport=transport, base_url="http://test") as client:
        response = await client.get("/api/v1/health")

    assert response.status_code == 200
    body = response.json()
    assert body["service"] == "patentyazar-python"
    assert body["status"] == "ok"
    assert set(body.keys()) == {
        "service",
        "status",
        "version",
        "python",
        "platform",
        "timestamp",
    }


@pytest.mark.asyncio
async def test_health_reports_python_version() -> None:
    transport = ASGITransport(app=app)
    async with AsyncClient(transport=transport, base_url="http://test") as client:
        response = await client.get("/api/v1/health")

    body = response.json()
    assert body["python"].startswith("3.")
