48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import requests
|
|
import json
|
|
import pytest
|
|
|
|
def test_normal_prediction():
|
|
"""Démo cas normal - Match entre deux équipes top 10"""
|
|
|
|
# Skip test if server is not running
|
|
try:
|
|
response = requests.get("http://localhost:8000/health", timeout=1)
|
|
if response.status_code != 200:
|
|
pytest.skip("API server not running or not healthy")
|
|
except requests.exceptions.RequestException:
|
|
pytest.skip("API server not running")
|
|
|
|
match = {
|
|
"team_1": "Natus Vincere",
|
|
"team_2": "FaZe Clan",
|
|
"rank_1": 1,
|
|
"rank_2": 2,
|
|
"map_name": "Mirage"
|
|
}
|
|
|
|
print("=" * 50)
|
|
print("CAS NORMAL - Prédiction Match Pro")
|
|
print("=" * 50)
|
|
print(f"\n📋 Input:")
|
|
print(json.dumps(match, indent=2))
|
|
|
|
# Appel API
|
|
response = requests.post("http://localhost:8000/predict", json=match)
|
|
|
|
print(f"\n✅ Réponse:")
|
|
result = response.json()
|
|
print(json.dumps(result, indent=2))
|
|
|
|
print(f"\n📊 Interprétation:")
|
|
winner = match['team_1'] if result['winner'] == 1 else match['team_2']
|
|
print(f"Gagnant prédit: {winner}")
|
|
print(f"Confiance: {result['probability']:.1%}")
|
|
print(f"Latence: {result['latency_ms']:.1f}ms")
|
|
|
|
# Vérifier dashboard Grafana
|
|
print(f"\n🎨 Dashboard: http://localhost:3000")
|
|
print(f"MLflow: http://localhost:5000")
|
|
|
|
if __name__ == "__main__":
|
|
test_normal_prediction() |