9f8bf041c3
fix: 修复测试配置和依赖检查 perf: 优化雪花算法性能 refactor: 清理冗余代码和未使用的导入 style: 统一代码格式和注释 test: 添加单元测试和集成测试 ci: 更新CI配置和构建脚本 chore: 更新依赖和配置文件
22 lines
991 B
Python
22 lines
991 B
Python
import asyncio
|
|
from httpx import AsyncClient
|
|
|
|
async def test():
|
|
async with AsyncClient(base_url='http://localhost:8080') as client:
|
|
# 先登录获取token
|
|
login_resp = await client.post('/api/auth/login', json={'username': 'admin', 'password': 'admin123'})
|
|
print('Login status:', login_resp.status_code)
|
|
if login_resp.status_code == 200:
|
|
token = login_resp.json().get('token')
|
|
print('Token:', token[:20] if token else 'None')
|
|
|
|
# 测试分页API - 使用正确的参数格式
|
|
headers = {'Authorization': f'Bearer {token}'}
|
|
page_resp = await client.get('/api/logs/login/page', params={'page': 0, 'size': 10}, headers=headers)
|
|
print('Page API status:', page_resp.status_code)
|
|
if page_resp.status_code != 200:
|
|
print('Error response:', page_resp.text[:500])
|
|
else:
|
|
print('Success:', page_resp.json())
|
|
|
|
asyncio.run(test()) |