# tests/test_api.py import pytest from fastapi.testclient import TestClient from app.main import app client = TestClient(app) def test_health_check(): """Vérifie que /health répond bien avec status ok""" response = client.get("/health") assert response.status_code == 200 assert response.json() == {"status": "ok"} def test_predict_positive(): """Vérifie qu'une phrase positive est détectée correctement""" response = client.post("/predict", json={"text": "I love this product, it's amazing!"}) assert response.status_code == 200 result = response.json() assert "sentiment" in result assert result["sentiment"] == "positive" def test_predict_negative(): """Vérifie qu'une phrase négative est détectée correctement""" response = client.post("/predict", json={"text": "I hate this, it is terrible."}) assert response.status_code == 200 result = response.json() assert "sentiment" in result assert result["sentiment"] == "negative"