Add FastAPI service, Dockerfile and compose
This commit is contained in:
27
webapp/tests/test_app.py
Normal file
27
webapp/tests/test_app.py
Normal 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
|
||||
Reference in New Issue
Block a user