feat: 初始化考培练系统项目
- 从服务器拉取完整代码 - 按框架规范整理项目结构 - 配置 Drone CI 测试环境部署 - 包含后端(FastAPI)、前端(Vue3)、管理端 技术栈: Vue3 + TypeScript + FastAPI + MySQL
This commit is contained in:
35
backend/tests/test_main.py
Normal file
35
backend/tests/test_main.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
主应用测试
|
||||
"""
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_root():
|
||||
"""测试根路径"""
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["name"] == "考培练系统"
|
||||
assert data["status"] == "running"
|
||||
assert "version" in data
|
||||
assert "timestamp" in data
|
||||
|
||||
|
||||
def test_health():
|
||||
"""测试健康检查端点"""
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"status": "healthy"}
|
||||
|
||||
|
||||
def test_api_health():
|
||||
"""测试API健康检查"""
|
||||
response = client.get("/api/v1/health")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "healthy"
|
||||
assert data["api_version"] == "v1"
|
||||
Reference in New Issue
Block a user