Spaces:
Runtime error
Runtime error
Download tests/test_api.py from abdelbarredazia/absdocker: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/abdelbarredazia/absdocker/resolve/main/tests/test_api.py
- Command line
-
hf download hf://spaces/abdelbarredazia/absdocker/tests/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/abdelbarredazia/absdocker/resolve/main/tests/test_api.py
1.01 kB
| # 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" | |