feat: 重构测试框架并优化代码结构
refactor(tests): 将e2e_tests迁移到tests_suite和api_integration_tests style: 为Java类添加文档注释 docs: 更新.gitignore和配置文件 test: 添加性能测试和Playwright测试脚本 chore: 清理旧测试文件和配置
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
文件管理API封装
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from httpx import AsyncClient
|
||||
|
||||
|
||||
class SysFileAPI:
|
||||
"""文件管理API"""
|
||||
|
||||
def __init__(self, client: AsyncClient):
|
||||
self.client = client
|
||||
self.base_path = "/api/files"
|
||||
|
||||
async def get_all(self) -> Any:
|
||||
"""获取所有文件"""
|
||||
return await self.client.get(self.base_path)
|
||||
|
||||
async def get_by_id(self, file_id: int) -> Any:
|
||||
"""根据ID获取文件信息"""
|
||||
return await self.client.get(f"{self.base_path}/{file_id}")
|
||||
|
||||
async def upload(self, file_path: str, create_by: str = "test") -> Any:
|
||||
"""上传文件"""
|
||||
with open(file_path, "rb") as f:
|
||||
files = {"file": f}
|
||||
data = {"createBy": create_by}
|
||||
return await self.client.post(f"{self.base_path}/upload", files=files, data=data)
|
||||
|
||||
async def download(self, file_name: str) -> Any:
|
||||
"""下载文件"""
|
||||
return await self.client.get(f"{self.base_path}/download/{file_name}")
|
||||
|
||||
async def preview(self, file_name: str) -> Any:
|
||||
"""预览文件"""
|
||||
return await self.client.get(f"{self.base_path}/preview/{file_name}")
|
||||
|
||||
async def delete(self, file_id: int) -> Any:
|
||||
"""删除文件"""
|
||||
return await self.client.delete(f"{self.base_path}/{file_id}")
|
||||
Reference in New Issue
Block a user