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

client = TestClient(app)

def test_home_endpoint():
    """Test de l'endpoint principal"""
    response = client.get("/")
    assert response.status_code == 200
    data = response.json()
    assert "message" in data
    assert "status" in data
    assert data["status"] == "running"

def test_health_endpoint():
    """Test du health check"""
    response = client.get("/health")
    assert response.status_code == 200
    data = response.json()
    assert data["status"] == "healthy"
    assert "service" in data

def test_metrics_endpoint():
    """Test des métriques Prometheus"""
    response = client.get("/metrics")
    assert response.status_code == 200
    assert "text/plain" in response.headers["content-type"]
    assert "http_requests_total" in response.text

def test_info_endpoint():
    """Test des informations"""
    response = client.get("/info")
    assert response.status_code == 200
    data = response.json()
    assert "python_version" in data
    assert "platform" in data

def test_env_endpoint():
    """Test des variables d'environnement"""
    response = client.get("/env")
    assert response.status_code == 200
    data = response.json()
    assert "ENV" in data