upload project source code

This commit is contained in:
2026-04-30 18:49:43 +08:00
commit 9b394ba682
2277 changed files with 660945 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
import sys
import os
import pytest
from fastapi.testclient import TestClient
# 导入 main 模块,确保路径正确
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from main import create_app
# 创建测试客户端
app = create_app()
@pytest.fixture(scope="module")
def test_client():
with TestClient(app) as client:
yield client

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
"""
测试文件
注意:使用普通的 def 定义测试函数,不要使用 async def
执行命令: pytest tests/test.py
"""
import pytest
from fastapi.testclient import TestClient
def test_check_health(test_client: TestClient):
"""测试健康检查接口"""
response = test_client.get("/common/health")
assert response.status_code == 200
assert response.json() == {"msg": "Healthy"}
# 运行所有测试
if __name__ == "__main__":
pytest.main(["-v", "tests/test_main.py"])