Files
FastapiAdmin/backend/tests/test_api_module_common.py
T
zhangtao 8949f6dc46 refactor(test, config, router): 整理代码结构与配置,优化导入顺序
1. 调整多个测试文件中TestClient的导入顺序,统一放到conftest导入之后
2. 删除后端配置中无用的WebSocket限流配置,统一使用全局200次/10秒的限流策略
3. 精简平台、系统模块的路由初始化注释文档
4. 优化conftest.py中的数据库初始化导入顺序
5. 调整初始化日志输出格式,更清晰易懂
6. 前端开发环境配置切回本地后端地址,注释远程服务地址
7. 重构路由类的变量命名,提升可读性
8. 简化动态路由热重载逻辑,移除冗余缓存变量
9. 重构注册路由的代码,统一限流配置,调整导入顺序和挂载逻辑
10. 删除冗余的v1接口层统一导出文件
2026-06-21 21:47:32 +08:00

36 lines
1.1 KiB
Python

"""
模块接口测试 —— module_common(公共模块)
每个接口一个测试用例,验证路由存在且返回码正确。
"""
from conftest import assert_route
from fastapi.testclient import TestClient
class TestHealth:
"""健康检查接口。"""
def test_health_check(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/common/health", expected_status=200)
def test_health_ready(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/common/health/ready", expected_status=200)
def test_health_live(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/common/health/live", expected_status=200)
class TestFile:
"""文件管理接口。"""
def test_upload_file(self, test_client: TestClient) -> None:
assert_route(test_client, "POST", "/common/file/upload")
def test_download_file(self, test_client: TestClient) -> None:
assert_route(
test_client,
"POST",
"/common/file/download",
json={"file_path": "test.txt", "delete": False},
)