refactor(test): 重构测试套件结构并优化测试配置

feat(test-suite): 新增测试套件模块,包含API测试客户端和测试配置
fix(api): 修复数据库实体和仓库的删除操作返回值
style(api): 统一数据库表名和字段命名
perf(api): 添加缓存注解提升配置查询性能
test(api): 添加H2测试数据库配置支持
chore: 清理旧的测试文件和脚本
This commit is contained in:
张翔
2026-04-01 20:57:24 +08:00
parent 24422c2c19
commit 1e3dc11d59
180 changed files with 15421 additions and 3797 deletions
+50
View File
@@ -0,0 +1,50 @@
"""
用户管理 API 客户端
"""
from httpx import AsyncClient
class UserAPI:
"""用户管理 API 客户端"""
def __init__(self, client: AsyncClient):
self.client = client
async def get_user_list(self):
"""获取用户列表"""
return await self.client.get('/api/users')
async def get_users_by_page(self, page: int = 0, size: int = 10, **kwargs):
"""分页获取用户列表,支持搜索和排序"""
params = {'page': page, 'size': size}
params.update(kwargs)
return await self.client.get('/api/users', params=params)
async def create_user(self, user_data):
"""创建用户"""
return await self.client.post('/api/users', json=user_data)
async def get_user_by_id(self, user_id):
"""根据ID获取用户"""
return await self.client.get(f'/api/users/{user_id}')
async def update_user(self, user_id, user_data):
"""更新用户"""
return await self.client.put(f'/api/users/{user_id}', json=user_data)
async def delete_user(self, user_id):
"""删除用户"""
return await self.client.delete(f'/api/users/{user_id}')
async def get_user_profile(self):
"""获取当前用户资料(调用get_user_by_id,使用token中的userId"""
return await self.client.get('/api/users/profile')
async def update_user_profile(self, profile_data):
"""更新当前用户资料(调用update_user,使用token中的userId"""
return await self.client.put('/api/users/profile', json=profile_data)
async def assign_roles(self, user_id, role_ids):
"""为用户分配角色"""
return await self.client.post(f'/api/users/{user_id}/roles', json=role_ids)