refactor(test): 重构测试套件结构并优化测试配置
feat(test-suite): 新增测试套件模块,包含API测试客户端和测试配置 fix(api): 修复数据库实体和仓库的删除操作返回值 style(api): 统一数据库表名和字段命名 perf(api): 添加缓存注解提升配置查询性能 test(api): 添加H2测试数据库配置支持 chore: 清理旧的测试文件和脚本
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
字典管理 API 客户端
|
||||
"""
|
||||
|
||||
from httpx import AsyncClient
|
||||
|
||||
|
||||
class DictTypeAPI:
|
||||
"""字典类型 API 客户端"""
|
||||
|
||||
def __init__(self, client: AsyncClient):
|
||||
self.client = client
|
||||
|
||||
async def get_type_list(self, page: int = 0, size: int = 10):
|
||||
"""获取字典类型列表"""
|
||||
return await self.client.get(f'/api/dict/types?page={page}&size={size}')
|
||||
|
||||
async def get_type_by_id(self, dict_type_id: int):
|
||||
"""根据ID获取字典类型"""
|
||||
return await self.client.get(f'/api/dict/types/{dict_type_id}')
|
||||
|
||||
async def create(self, dict_type_data):
|
||||
"""创建字典类型"""
|
||||
return await self.client.post('/api/dict/types', json=dict_type_data)
|
||||
|
||||
async def update(self, dict_type_id: int, dict_type_data):
|
||||
"""更新字典类型"""
|
||||
return await self.client.put(f'/api/dict/types/{dict_type_id}', json=dict_type_data)
|
||||
|
||||
async def delete(self, dict_type_id: int):
|
||||
"""删除字典类型"""
|
||||
return await self.client.delete(f'/api/dict/types/{dict_type_id}')
|
||||
|
||||
|
||||
class DictDataAPI:
|
||||
"""字典数据 API 客户端"""
|
||||
|
||||
def __init__(self, client: AsyncClient):
|
||||
self.client = client
|
||||
|
||||
async def get_dict_list(self, page: int = 0, size: int = 10):
|
||||
"""获取字典数据列表"""
|
||||
return await self.client.get(f'/api/dict?page={page}&size={size}')
|
||||
|
||||
async def get_dict_by_id(self, dict_id: int):
|
||||
"""根据ID获取字典数据"""
|
||||
return await self.client.get(f'/api/dict/{dict_id}')
|
||||
|
||||
async def create(self, dict_data):
|
||||
"""创建字典数据"""
|
||||
return await self.client.post('/api/dict', json=dict_data)
|
||||
|
||||
async def update(self, dict_id: int, dict_data):
|
||||
"""更新字典数据"""
|
||||
return await self.client.put(f'/api/dict/{dict_id}', json=dict_data)
|
||||
|
||||
async def delete(self, dict_id: int):
|
||||
"""删除字典数据"""
|
||||
return await self.client.delete(f'/api/dict/{dict_id}')
|
||||
|
||||
|
||||
class DictAPI(DictTypeAPI, DictDataAPI):
|
||||
"""字典管理 API (组合)"""
|
||||
pass
|
||||
Reference in New Issue
Block a user