24 lines
663 B
Python
24 lines
663 B
Python
from fastapi.testclient import TestClient
|
|
from app.main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
def test_root():
|
|
response = client.get("/")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"status": "ok", "version": "1.0.0"}
|
|
|
|
def test_health():
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"healthy": True}
|
|
|
|
def test_get_item():
|
|
response = client.get("/items/1")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"item_id": 1, "name": "Item 1"}
|
|
|
|
def test_get_item_invalid():
|
|
response = client.get("/items/abc")
|
|
assert response.status_code == 422
|