91 lines
3.1 KiB
Python
91 lines
3.1 KiB
Python
from app.services.ai_pmo.draft_confirm_handler import DraftConfirmHandler
|
|
from app.services.ai_pmo.ai_pmo_kernel_ingress_flow import mixin_auto
|
|
from app.services.adaptive_rag_service.mixin_deep_guard_answer import AdaptiveRAGDeepGuardAnswerMixin
|
|
|
|
|
|
def test_parse_action_confirm() -> None:
|
|
action, note = DraftConfirmHandler.parse_action_from_text(message_text="确认")
|
|
assert action == "confirm"
|
|
assert note == ""
|
|
|
|
|
|
def test_parse_action_revise_with_note() -> None:
|
|
action, note = DraftConfirmHandler.parse_action_from_text(message_text="修改 改成每周跟进")
|
|
assert action == "revise"
|
|
assert note == "改成每周跟进"
|
|
|
|
|
|
def test_parse_action_cancel() -> None:
|
|
action, note = DraftConfirmHandler.parse_action_from_text(message_text="取消")
|
|
assert action == "cancel"
|
|
assert note == ""
|
|
|
|
|
|
def test_parse_action_yes_as_confirm() -> None:
|
|
action, note = DraftConfirmHandler.parse_action_from_text(message_text="yes")
|
|
assert action == "confirm"
|
|
assert note == ""
|
|
|
|
|
|
def test_kernel_ingress_mixin_auto_safe_int_regression() -> None:
|
|
assert callable(mixin_auto._safe_int)
|
|
assert mixin_auto._safe_int("123") == 123
|
|
assert mixin_auto._safe_int("") is None
|
|
assert mixin_auto._safe_int(None) is None
|
|
|
|
|
|
def test_adaptive_rag_process_entry_and_mixed_format() -> None:
|
|
mixin = AdaptiveRAGDeepGuardAnswerMixin()
|
|
assert mixin._is_ai_pmo_process_entry("pmflow_manual") is True
|
|
assert mixin._is_ai_pmo_process_entry("feishu") is False
|
|
|
|
mixed = mixin._format_mixed_two_block_output(
|
|
answer_text="[回答] 接口契约已对齐\n[已收到需求] 新增任务创建确认流",
|
|
question_part="现在进展怎么样",
|
|
signal_part="补齐任务确认",
|
|
)
|
|
assert mixed.startswith("[回答] ")
|
|
assert "\n[已收到需求] " in mixed
|
|
assert mixed.endswith(",已入库处理")
|
|
|
|
|
|
def test_adaptive_rag_select_scene_prompt_prefers_mixed() -> None:
|
|
mixin = AdaptiveRAGDeepGuardAnswerMixin()
|
|
scene_key, prompt = mixin._select_scene_prompt(
|
|
question="现在进展怎么样?",
|
|
project_id=7,
|
|
asked_via="pmflow_manual",
|
|
message_intent="mixed",
|
|
mixed_signal_part="新增任务确认流",
|
|
conversation_text="无",
|
|
context_blocks_text="无",
|
|
system_snapshot={},
|
|
user_snapshot={},
|
|
system_snapshot_text="{}",
|
|
user_snapshot_text="{}",
|
|
relevance_max=0.0,
|
|
)
|
|
assert scene_key == "mixed"
|
|
assert "现在进展怎么样" in prompt
|
|
assert "新增任务确认流" in prompt
|
|
|
|
|
|
def test_adaptive_rag_select_scene_prompt_ai_pmo_manual_entry() -> None:
|
|
mixin = AdaptiveRAGDeepGuardAnswerMixin()
|
|
scene_key, prompt = mixin._select_scene_prompt(
|
|
question="帮我总结这个项目",
|
|
project_id=9,
|
|
asked_via="pmflow_manual",
|
|
message_intent=None,
|
|
mixed_signal_part=None,
|
|
conversation_text="无",
|
|
context_blocks_text="无",
|
|
system_snapshot={},
|
|
user_snapshot={},
|
|
system_snapshot_text="{}",
|
|
user_snapshot_text="{}",
|
|
relevance_max=0.0,
|
|
)
|
|
assert scene_key == "ai_pmo"
|
|
assert "帮我总结这个项目" in prompt
|