21 lines
615 B
Python
21 lines
615 B
Python
from fastapi.testclient import TestClient
|
|
from main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_root_endpoint():
|
|
response = client.get("/")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"message": "Welcome to your FastAPI application"}
|
|
|
|
|
|
def test_health_endpoint():
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"status": "healthy"}
|
|
|
|
|
|
def test_cors_headers():
|
|
response = client.get("/", headers={"Origin": "http://localhost:5173"})
|
|
assert response.headers["access-control-allow-origin"] == "http://localhost:5173"
|