Files
meeting-room/backend/test_minutes.py

70 lines
2.1 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
"""
测试会议纪要生成
"""
import requests
API_BASE = 'http://localhost:8000/api/v1'
def test_minutes():
# 登录
res = requests.post(f'{API_BASE}/auth/login/', json={
'username': 'test',
'password': 'test123'
})
token = res.json()['token']
headers = {'Authorization': f'Bearer {token}'}
# 创建会议
res = requests.post(f'{API_BASE}/meetings/', json={
'topic': '会议纪要测试会议'
}, headers=headers)
meeting_id = res.json()['id']
print(f"✅ 创建会议:{meeting_id}")
# 发送几条消息
messages = [
"大家好,开始今天的会议!",
"我来汇报一下 Q2 的进度。",
"这个项目需要更多资源支持。",
"好的,我会跟进这件事。",
]
for msg in messages:
requests.post(
f'{API_BASE}/meetings/{meeting_id}/send_message/',
json={'content': msg, 'requires_response': '资源' in msg},
headers=headers
)
print(f"✅ 发送 {len(messages)} 条消息")
# 生成纪要JSON
res = requests.get(f'{API_BASE}/meetings/{meeting_id}/minutes/')
if res.status_code == 200:
data = res.json()
print(f"\n✅ 会议纪要 (JSON):")
print(f" 主题:{data['topic']}")
print(f" 消息数:{data['message_count']}")
print(f" 摘要:{data['summary'][:100]}...")
print(f" 待办:{len(data['todos'])}")
else:
print(f"❌ 生成纪要失败:{res.text}")
return False
# 生成纪要Markdown- 用 minutes action
res = requests.get(f'{API_BASE}/meetings/{meeting_id}/minutes/?output=markdown')
if res.status_code == 200:
data = res.json()
print(f"\n✅ 会议纪要 (Markdown):")
print(data['markdown'][:500])
else:
print(f"❌ 生成 Markdown 失败:{res.text}")
return False
print("\n✅ 会议纪要测试通过!")
return True
if __name__ == '__main__':
test_minutes()