Skip to content

Commit 95babfd

Browse files
baijumclaude
andcommitted
feat: add test suite for health and root endpoints
- TestClient-based tests: health returns 200 + {"status": "ok"}, POST /health returns 405, GET / returns 200 - conftest.py with shared client fixture - requirements-test.txt with pytest and httpx Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1652fc5 commit 95babfd

5 files changed

Lines changed: 23 additions & 0 deletions

File tree

requirements-test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest>=7.0
2+
httpx>=0.24.0

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
from fastapi.testclient import TestClient
3+
4+
from app.main import app
5+
6+
7+
@pytest.fixture
8+
def client():
9+
return TestClient(app)

tests/test_app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def test_root_returns_200(client):
2+
response = client.get("/")
3+
assert response.status_code == 200

tests/test_health.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def test_health_returns_200(client):
2+
response = client.get("/health")
3+
assert response.status_code == 200
4+
assert response.json() == {"status": "ok"}
5+
6+
7+
def test_health_post_not_allowed(client):
8+
response = client.post("/health")
9+
assert response.status_code == 405

0 commit comments

Comments
 (0)