diff --git a/ressources/__pycache__/app.cpython-311.pyc b/ressources/__pycache__/app.cpython-311.pyc index 888f33c..d863e2d 100644 Binary files a/ressources/__pycache__/app.cpython-311.pyc and b/ressources/__pycache__/app.cpython-311.pyc differ diff --git a/ressources/__pycache__/test_app.cpython-311-pytest-8.2.0.pyc b/ressources/__pycache__/test_app.cpython-311-pytest-8.2.0.pyc index a339254..bd70633 100644 Binary files a/ressources/__pycache__/test_app.cpython-311-pytest-8.2.0.pyc and b/ressources/__pycache__/test_app.cpython-311-pytest-8.2.0.pyc differ diff --git a/ressources/app.py b/ressources/app.py index d7e75f2..eee358d 100644 --- a/ressources/app.py +++ b/ressources/app.py @@ -38,5 +38,14 @@ def logs_critical(): return jsonify({"critical_count": seuil, "alerte": alerte}) +@app.route("/logs/stats") +def logs_stats(): + total = sum(LOG_SUMMARY.values()) + return jsonify({ + "total": total, + "breakdown": LOG_SUMMARY + }) + + if __name__ == "__main__": app.run(debug=True, port=5001) diff --git a/ressources/test_app.py b/ressources/test_app.py index ce56a43..d5f9dce 100644 --- a/ressources/test_app.py +++ b/ressources/test_app.py @@ -57,3 +57,13 @@ def test_logs_critical_alerte(client): assert "critical_count" in data assert "alerte" in data assert data["alerte"] is True + + +def test_logs_stats(client): + """La route /logs/stats retourne le total et le détail.""" + response = client.get("/logs/stats") + assert response.status_code == 200 + data = response.get_json() + assert "total" in data + assert "breakdown" in data + assert data["total"] == 185