20 lines
514 B
Python
20 lines
514 B
Python
from api_fastapi import app
|
|
from fastapi.testclient import TestClient
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_health() -> None:
|
|
resp = client.get("/health")
|
|
assert resp.status_code == 200
|
|
assert resp.json() == {"status": "ok"}
|
|
|
|
|
|
def test_echo_validation() -> None:
|
|
ok = client.post("/echo", json={"message": "devops"})
|
|
assert ok.status_code == 200
|
|
assert ok.json() == {"echoed": "devops", "length": 6}
|
|
|
|
bad = client.post("/echo", json={"message": " "})
|
|
assert bad.status_code == 400
|