80 lines
2.4 KiB
Python
80 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
测试修复后的系统功能
|
|
"""
|
|
|
|
import requests
|
|
import time
|
|
import json
|
|
|
|
def test_system():
|
|
"""测试系统功能"""
|
|
base_url = "http://localhost:5000"
|
|
|
|
print("🧪 开始测试修复后的系统...")
|
|
print("=" * 50)
|
|
|
|
# 测试1: 检查系统状态
|
|
print("1. 测试系统状态...")
|
|
try:
|
|
response = requests.get(f"{base_url}/api/status", timeout=10)
|
|
if response.status_code == 200:
|
|
status = response.json()
|
|
print(f" ✅ 系统状态: {status}")
|
|
else:
|
|
print(f" ❌ 状态检查失败: {response.status_code}")
|
|
except Exception as e:
|
|
print(f" ❌ 状态检查异常: {e}")
|
|
|
|
# 测试2: 检查数据统计
|
|
print("\n2. 测试数据统计...")
|
|
try:
|
|
response = requests.get(f"{base_url}/api/data/stats", timeout=10)
|
|
if response.status_code == 200:
|
|
stats = response.json()
|
|
print(f" ✅ 数据统计: {stats}")
|
|
else:
|
|
print(f" ❌ 统计检查失败: {response.status_code}")
|
|
except Exception as e:
|
|
print(f" ❌ 统计检查异常: {e}")
|
|
|
|
# 测试3: 检查数据列表
|
|
print("\n3. 测试数据列表...")
|
|
try:
|
|
response = requests.get(f"{base_url}/api/data/list", timeout=10)
|
|
if response.status_code == 200:
|
|
data_list = response.json()
|
|
print(f" ✅ 数据列表: {data_list}")
|
|
else:
|
|
print(f" ❌ 列表检查失败: {response.status_code}")
|
|
except Exception as e:
|
|
print(f" ❌ 列表检查异常: {e}")
|
|
|
|
# 测试4: 测试文本搜索(如果系统已初始化)
|
|
print("\n4. 测试文本搜索...")
|
|
try:
|
|
search_data = {
|
|
"query": "测试查询",
|
|
"top_k": 3
|
|
}
|
|
response = requests.post(f"{base_url}/api/search/text_to_text",
|
|
json=search_data, timeout=10)
|
|
if response.status_code == 200:
|
|
result = response.json()
|
|
print(f" ✅ 文本搜索: {result}")
|
|
else:
|
|
print(f" ❌ 文本搜索失败: {response.status_code}")
|
|
except Exception as e:
|
|
print(f" ❌ 文本搜索异常: {e}")
|
|
|
|
print("\n" + "=" * 50)
|
|
print("🎉 测试完成!")
|
|
|
|
if __name__ == "__main__":
|
|
# 等待系统启动
|
|
print("⏳ 等待系统启动...")
|
|
time.sleep(5)
|
|
|
|
test_system()
|