mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-20 20:39:55 +00:00
refactor: 优化代码结构和可读性 feat: 添加http_limit模块实现请求限制功能 fix: 修复异步任务中使用time.sleep的问题 chore: 更新依赖项并添加pytest测试框架 docs: 更新项目描述信息 perf: 优化Redis序列化方式使用JSON替代pickle test: 添加测试相关配置和依赖
22 lines
513 B
Python
22 lines
513 B
Python
"""
|
|
测试文件
|
|
|
|
注意:使用普通的 def 定义测试函数,不要使用 async def
|
|
执行命令: pytest tests/test.py
|
|
"""
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
def test_check_health(test_client: TestClient) -> None:
|
|
"""测试健康检查接口"""
|
|
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"])
|