mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-09-20 08:58:15 +00:00
- test_prompt_manager.py: 验证系统提示词包含5步流程、所有工具列表、无Python函数注记 - test_web_api.py: 验证关键API端点存在、静态文件路径正确、提示词可加载
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Tests for Web API endpoints"""
|
|
|
|
|
|
def test_web_api_imports():
|
|
"""Web API 模块应能正常导入"""
|
|
from core import web_api
|
|
assert web_api is not None
|
|
|
|
|
|
def test_web_api_has_endpoints():
|
|
"""Web API 应定义关键端点"""
|
|
from core.web_api import app
|
|
rules = [r.rule for r in app.url_map.iter_rules()]
|
|
expected_endpoints = [
|
|
'/api/settings',
|
|
'/api/message',
|
|
'/api/tools/execute',
|
|
'/api/status',
|
|
'/api/history',
|
|
'/api/check-auth',
|
|
]
|
|
for endpoint in expected_endpoints:
|
|
assert endpoint in rules, f"缺少端点: {endpoint}"
|
|
|
|
|
|
def test_web_api_static_files():
|
|
"""Web API 应正确配置静态文件路径"""
|
|
from core.web_api import app
|
|
assert app.static_folder is not None
|
|
assert 'graph.html' in app.static_url_path or app.static_folder is not None
|
|
|
|
|
|
def test_ui_index_exists():
|
|
"""Web UI 的核心页面应存在"""
|
|
import os
|
|
from core.web_api import _ui_dir
|
|
for page in ['graph.html', 'index.html']:
|
|
path = os.path.join(_ui_dir, 'static', page)
|
|
assert os.path.exists(path), f"缺少静态页面: {page}"
|
|
for template in ['login.html', 'settings.html', 'setup.html']:
|
|
path = os.path.join(_ui_dir, 'templates', template)
|
|
assert os.path.exists(path), f"缺少模板: {template}"
|
|
|
|
|
|
def test_system_prompt_integration():
|
|
"""系统提示词应能被后端正确加载"""
|
|
from core.prompts import PromptManager
|
|
pm = PromptManager()
|
|
prompt = pm.get_system_prompt()
|
|
assert prompt is not None
|
|
assert len(prompt) > 200
|