Add FastAPI service, Dockerfile and compose

This commit is contained in:
rezayaghobi-dev
2026-10-03 19:08:48 +03:30
commit a1973b97ff
10 changed files with 119 additions and 0 deletions

27
webapp/tests/test_app.py Normal file
View File

@@ -0,0 +1,27 @@
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_index():
r = client.get("/")
assert r.status_code == 200
def test_health():
r = client.get("/health")
assert r.status_code == 200
assert r.json() == {"status": "ok"}
def test_error_endpoint_returns_500():
assert client.get("/error").status_code == 500
def test_metrics_exposed():
client.get("/health")
r = client.get("/metrics")
assert r.status_code == 200
assert "http_requests_total" in r.text