Files
FastapiAdmin/backend/tests/test_api_module_ai.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

47 lines
1.4 KiB
Python

"""
模块接口测试 —— module_ai(AI 对话模块)
动态路由映射:module_ai → /ai
每个接口一个测试用例,覆盖会话 CRUD 与 AI 对话。
"""
from conftest import assert_route
from fastapi.testclient import TestClient
class TestAiChat:
"""AI 对话接口。"""
def test_ai_chat_list(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/ai/chat/list")
def test_ai_chat_detail(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/ai/chat/detail/test_session")
def test_ai_chat_create(self, test_client: TestClient) -> None:
assert_route(
test_client,
"POST",
"/ai/chat/create",
json={"title": "测试会话"},
)
def test_ai_chat_update(self, test_client: TestClient) -> None:
assert_route(
test_client,
"PUT",
"/ai/chat/update/test_session",
json={"title": "更新会话"},
)
def test_ai_chat_delete(self, test_client: TestClient) -> None:
assert_route(test_client, "DELETE", "/ai/chat/delete", json=["test_session"])
def test_ai_chat_non_stream(self, test_client: TestClient) -> None:
assert_route(
test_client,
"POST",
"/ai/chat/ai-chat",
json={"message": "你好", "session_id": "test_session"},
)