32 lines
909 B
Python
32 lines
909 B
Python
"""健康检查接口测试"""
|
|
|
|
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class TestHealthAPI:
|
|
"""健康检查 API 测试"""
|
|
|
|
@pytest.mark.api
|
|
@pytest.mark.asyncio
|
|
async def test_health_check(self, client: AsyncClient):
|
|
"""测试健康检查端点"""
|
|
response = await client.get("/health")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["code"] == 0
|
|
assert data["data"]["status"] == "healthy"
|
|
assert "version" in data["data"]
|
|
|
|
@pytest.mark.api
|
|
@pytest.mark.asyncio
|
|
async def test_root_endpoint(self, client: AsyncClient):
|
|
"""测试根路径端点"""
|
|
response = await client.get("/")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["code"] == 0
|
|
assert "智能项目定价模型" in data["data"]["name"]
|