55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
|
|
# -*- coding: utf-8 -*-
|
||
|
|
"""
|
||
|
|
测试模板选择功能
|
||
|
|
"""
|
||
|
|
from src.flask_prompt_master import create_app, db
|
||
|
|
from src.flask_prompt_master.models.models import PromptTemplate
|
||
|
|
|
||
|
|
def test_template_selection():
|
||
|
|
"""测试模板选择功能"""
|
||
|
|
app = create_app()
|
||
|
|
|
||
|
|
with app.app_context():
|
||
|
|
print("=" * 50)
|
||
|
|
print("模板选择功能测试")
|
||
|
|
print("=" * 50)
|
||
|
|
|
||
|
|
try:
|
||
|
|
# 获取所有模板
|
||
|
|
templates = PromptTemplate.query.all()
|
||
|
|
print(f"📋 总模板数: {len(templates)}")
|
||
|
|
|
||
|
|
if not templates:
|
||
|
|
print("❌ 没有找到任何模板")
|
||
|
|
return
|
||
|
|
|
||
|
|
# 显示模板信息
|
||
|
|
print("\n📝 模板列表:")
|
||
|
|
for i, template in enumerate(templates, 1):
|
||
|
|
print(f" {i}. ID: {template.id}")
|
||
|
|
print(f" 名称: {template.name}")
|
||
|
|
print(f" 分类: {template.category}")
|
||
|
|
print(f" 是否默认: {template.is_default}")
|
||
|
|
print()
|
||
|
|
|
||
|
|
# 查找默认模板
|
||
|
|
default_template = PromptTemplate.query.filter_by(is_default=True).first()
|
||
|
|
if default_template:
|
||
|
|
print(f"✅ 找到默认模板: {default_template.name} (ID: {default_template.id})")
|
||
|
|
else:
|
||
|
|
print("⚠️ 没有找到默认模板")
|
||
|
|
|
||
|
|
# 查找第一个模板
|
||
|
|
first_template = templates[0]
|
||
|
|
print(f"✅ 第一个模板: {first_template.name} (ID: {first_template.id})")
|
||
|
|
|
||
|
|
print("\n" + "=" * 50)
|
||
|
|
print("✅ 模板选择功能测试完成!")
|
||
|
|
print("=" * 50)
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"❌ 测试过程中出现错误: {str(e)}")
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
test_template_selection()
|