mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 13:05:18 +00:00
1. 调整后端模块路由与插件文件结构,迁移部分模块代码至api/v1目录 2. 优化代码注释格式与文档字符串,简化冗余代码 3. 添加监控仪表盘、工单评论等新模块功能 4. 修复前端部分组件交互逻辑与类型定义 5. 清理冗余的初始化数据与废弃配置文件 6. 新增租户注册表单字段与国际化支持 7. 优化HTTP请求拦截器与快捷键功能
122 lines
4.6 KiB
Python
122 lines
4.6 KiB
Python
"""模块接口测试 —— module_monitor(系统监控)
|
|
认证数据测试:admin 登录后验证监控接口数据。
|
|
"""
|
|
|
|
from conftest import assert_route
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
class TestCache:
|
|
"""缓存监控接口。"""
|
|
|
|
def test_cache_info(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "GET", "/monitor/cache/info", auth=auth_headers)
|
|
|
|
def test_cache_names(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "GET", "/monitor/cache/get/names", auth=auth_headers)
|
|
|
|
def test_cache_keys(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "GET", "/monitor/cache/get/keys/test", auth=auth_headers)
|
|
|
|
def test_cache_value(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "GET", "/monitor/cache/get/value/test/key", auth=auth_headers)
|
|
|
|
def test_cache_delete_name(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "DELETE", "/monitor/cache/delete/name/test", auth=auth_headers)
|
|
|
|
def test_cache_delete_key(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "DELETE", "/monitor/cache/delete/key/test", auth=auth_headers)
|
|
|
|
def test_cache_clear_all(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "DELETE", "/monitor/cache/clear", auth=auth_headers)
|
|
|
|
|
|
class TestServer:
|
|
"""服务器监控接口。"""
|
|
|
|
def test_server_info(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "GET", "/monitor/server/info", auth=auth_headers)
|
|
|
|
|
|
class TestOnline:
|
|
"""在线用户监控接口。"""
|
|
|
|
def test_online_list(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "GET", "/monitor/online/list", auth=auth_headers)
|
|
|
|
def test_online_delete(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
import json
|
|
|
|
assert_route(
|
|
test_client,
|
|
"DELETE",
|
|
"/monitor/online/delete",
|
|
auth=auth_headers,
|
|
content=json.dumps("test-session"),
|
|
headers={"Content-Type": "application/json"},
|
|
)
|
|
|
|
def test_online_clear(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "DELETE", "/monitor/online/clear", auth=auth_headers)
|
|
|
|
|
|
class TestResource:
|
|
"""资源管理接口。"""
|
|
|
|
def test_resource_list(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "GET", "/monitor/resource/list", auth=auth_headers)
|
|
|
|
def test_resource_delete(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
import json
|
|
|
|
assert_route(
|
|
test_client,
|
|
"DELETE",
|
|
"/monitor/resource/delete",
|
|
auth=auth_headers,
|
|
content=json.dumps(["/nonexistent"]),
|
|
headers={"Content-Type": "application/json"},
|
|
)
|
|
|
|
def test_resource_create_dir(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(
|
|
test_client,
|
|
"POST",
|
|
"/monitor/resource/mkdir",
|
|
auth=auth_headers,
|
|
json={"name": "test_dir", "parent_path": "/"},
|
|
)
|
|
|
|
def test_resource_rename(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(
|
|
test_client,
|
|
"POST",
|
|
"/monitor/resource/rename",
|
|
auth=auth_headers,
|
|
json={"old_path": "/old.txt", "new_path": "/new.txt"},
|
|
)
|
|
|
|
def test_resource_copy(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(
|
|
test_client,
|
|
"POST",
|
|
"/monitor/resource/copy",
|
|
auth=auth_headers,
|
|
json={"source_path": "/src.txt", "target_path": "/dst.txt"},
|
|
)
|
|
|
|
def test_resource_move(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(
|
|
test_client,
|
|
"POST",
|
|
"/monitor/resource/move",
|
|
auth=auth_headers,
|
|
json={"source_path": "/src.txt", "target_path": "/dst.txt"},
|
|
)
|
|
|
|
def test_resource_upload(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "POST", "/monitor/resource/upload", auth=auth_headers)
|
|
|
|
def test_resource_export(self, test_client: TestClient, auth_headers: dict) -> None:
|
|
assert_route(test_client, "POST", "/monitor/resource/export", auth=auth_headers)
|