Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified ressources/__pycache__/app.cpython-311.pyc
Binary file not shown.
Binary file modified ressources/__pycache__/test_app.cpython-311-pytest-8.2.0.pyc
Binary file not shown.
9 changes: 9 additions & 0 deletions ressources/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 10 additions & 0 deletions ressources/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading