"""健康检查 API 测试""" import pytest class TestHealthAPI: """测试健康检查端点""" @pytest.mark.asyncio async def test_root_endpoint(self, client): """测试根端点 /""" response = await client.get("/") assert response.status_code == 200 data = response.json() assert "message" in data assert "status" in data assert data["status"] == "running" @pytest.mark.asyncio async def test_health_endpoint(self, client): """测试健康检查端点 /health""" response = await client.get("/health") assert response.status_code == 200 data = response.json() assert data["status"] == "healthy" assert "timestamp" in data assert "database" in data assert "scheduler" in data assert "version" in data @pytest.mark.asyncio async def test_health_endpoint_structure(self, client): """测试健康检查端点返回结构""" response = await client.get("/health") data = response.json() assert "status" in data assert "timestamp" in data assert "database" in data assert "scheduler" in data assert "version" in data # 验证数据类型 assert isinstance(data["status"], str) assert isinstance(data["timestamp"], str) assert isinstance(data["database"], str) assert isinstance(data["scheduler"], str) assert isinstance(data["version"], str)