from fastapi.testclient import TestClient
from app.main import app


def get_client():
    # Disable lifespan to avoid external connections (DB/Redis) during unit tests
    return TestClient(app, lifespan="off")


def test_root():
    client = get_client()
    resp = client.get("/")
    assert resp.status_code == 200
    data = resp.json()
    assert data.get("service") == "Mana Pige Auth Service"
    assert data.get("status") == "running"


def test_health_endpoint_structure():
    client = get_client()
    resp = client.get("/health")
    # Health may be unhealthy in unit tests (no DB/Redis), but shape should be correct
    assert resp.status_code == 200
    data = resp.json()
    assert "status" in data
