Spaces:
Sleeping
Sleeping
Download tests/integration/test_monitoring.py from Lordemarco/sentiment-fastapi: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/Lordemarco/sentiment-fastapi/resolve/main/tests/integration/test_monitoring.py
- Command line
-
hf download hf://spaces/Lordemarco/sentiment-fastapi/tests/integration/test_monitoring.py
-
curl -L -o test_monitoring.py https://huggingface.co/spaces/Lordemarco/sentiment-fastapi/resolve/main/tests/integration/test_monitoring.py
1.01 kB
| import os | |
| import json | |
| import pytest | |
| from src.monitoring import main, REPORTS_DIR | |
| METRICS_PATH = os.path.join(REPORTS_DIR, "metrics.json") | |
| def cleanup_metrics(): | |
| """Rimuove il file metrics.json prima e dopo i test.""" | |
| if os.path.exists(METRICS_PATH): | |
| os.remove(METRICS_PATH) | |
| yield | |
| if os.path.exists(METRICS_PATH): | |
| os.remove(METRICS_PATH) | |
| def test_monitoring_creates_metrics(): | |
| """Verifica che il monitoring crei correttamente il file metrics.json e contenga i dati previsti.""" | |
| main() | |
| assert os.path.exists(METRICS_PATH), "metrics.json non è stato generato" | |
| with open(METRICS_PATH, "r") as f: | |
| metrics = json.load(f) | |
| assert "TweetEval" in metrics, "Mancano metriche TweetEval" | |
| assert "YouTube" in metrics, "Mancano metriche YouTube" | |
| for dataset_name, data in metrics.items(): | |
| assert "accuracy" in data, f"Manca accuracy per {dataset_name}" | |
| assert "f1" in data, f"Manca F1 per {dataset_name}" | |