You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB
Python

"""
Test health endpoint
"""
import pytest
from fastapi.testclient import TestClient
def test_health_check(client: TestClient):
"""Test health check endpoint"""
response = client.get("/api/v1/health")
assert response.status_code == 200
data = response.json()
# Check required fields
assert "status" in data
assert "version" in data
assert "database" in data
assert "cache" in data
assert "sec_data_available" in data
assert "timestamp" in data
# Version should match
assert data["version"] == "1.0.0"
# Status should be string
assert isinstance(data["status"], str)
assert data["status"] in ["healthy", "degraded", "unhealthy"]
def test_health_check_response_format(client: TestClient):
"""Test health check response format"""
response = client.get("/api/v1/health")
assert response.status_code == 200
assert response.headers["content-type"] == "application/json"
data = response.json()
# Check data types
assert isinstance(data["status"], str)
assert isinstance(data["version"], str)
assert isinstance(data["database"], str)
assert isinstance(data["cache"], str)
assert isinstance(data["sec_data_available"], bool)
assert isinstance(data["timestamp"], str)