48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""大周天内驱力 prompt 构建纯函数测试。"""
|
|
|
|
from app.modules.big_cycle.prompts import EvaluationSnapshot
|
|
from app.modules.drive.prompts import build_drive_extraction_messages
|
|
|
|
|
|
def _snapshot() -> EvaluationSnapshot:
|
|
return EvaluationSnapshot(
|
|
character_id="character_x",
|
|
memory_count=15,
|
|
recent_memories=[("用户偏好简洁", "用户偏好简洁直接的回答")],
|
|
personality_summary="身份:魂镜",
|
|
world_entity_count=4,
|
|
conclusion="近期对话偏技术,存在项目背景缺口",
|
|
)
|
|
|
|
|
|
def test_messages_return_system_user_pair() -> None:
|
|
system, user = build_drive_extraction_messages(_snapshot())
|
|
assert isinstance(system, str) and isinstance(user, str)
|
|
assert system and user
|
|
|
|
|
|
def test_system_describes_contract_fields() -> None:
|
|
system, _ = build_drive_extraction_messages(_snapshot())
|
|
for token in (
|
|
"question",
|
|
"source",
|
|
"expected_value",
|
|
"urgency",
|
|
"risk_level",
|
|
"subgoals",
|
|
):
|
|
assert token in system
|
|
|
|
|
|
def test_system_lists_sources() -> None:
|
|
system, _ = build_drive_extraction_messages(_snapshot())
|
|
for src in ("world_uncertainty", "memory_gap", "reflection", "goal_tension"):
|
|
assert src in system
|
|
|
|
|
|
def test_user_includes_snapshot_signals() -> None:
|
|
_, user = build_drive_extraction_messages(_snapshot())
|
|
assert "用户偏好简洁" in user
|
|
assert "身份:魂镜" in user
|
|
assert "15" in user
|