53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""
|
|
Test health and version endpoints.
|
|
"""
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
from main import app
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
"""Create test client."""
|
|
return TestClient(app)
|
|
|
|
|
|
class TestHealthEndpoint:
|
|
"""Tests for the /health endpoint."""
|
|
|
|
def test_health_returns_200(self, client):
|
|
"""Test that health check returns 200 OK."""
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
|
|
def test_health_response_structure(self, client):
|
|
"""Test health response contains expected JSON structure."""
|
|
response = client.get("/health")
|
|
assert response.json()["status"] == "healthy"
|
|
|
|
def test_api_v1_health_exists(self, client):
|
|
"""Test alternative /api/v1/health path works."""
|
|
# Note: This endpoint is not yet implemented - placeholder test
|
|
response = client.get("/api/v1/health")
|
|
assert response.status_code == 200
|
|
|
|
|
|
class TestVersionEndpoint:
|
|
"""Tests for the /api/v1/version endpoint."""
|
|
|
|
def test_version_returns_200(self, client):
|
|
"""Test that version endpoint returns 200 OK."""
|
|
response = client.get("/api/v1/version")
|
|
assert response.status_code == 200
|
|
|
|
def test_version_response_format(self, client):
|
|
"""Test version response format validation."""
|
|
response = client.get("/api/v1/version")
|
|
data = response.json()
|
|
assert "version" in data
|
|
assert "application" in data
|
|
# Version should be in format like v0.1.0
|
|
assert isinstance(data["version"], str)
|