| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- from app.main_decision_text import (
- parse_goal_text,
- parse_objective_text,
- plan_mode_label,
- plan_path_summary,
- )
- def test_objective_parser_prefers_real_target_statement_over_value_proposition():
- value = """## 选题价值主张
- 这是选题价值,不是目标。
- ## 账号价值主张
- 这是账号价值。
- ## 创作总目标
- ### 目标 1
- - 目标语句:形成清晰可执行的内容主线。
- - 通过标准:必须包含完整结构。
- ### 目标 2
- - 目标语句:补齐可靠的数据说明。
- ## 领域评估维度
- ### 领域维度 1
- - name:行业事实准确性
- """
- parsed = parse_objective_text(value)
- assert parsed["headline"] == "形成清晰可执行的内容主线。"
- assert parsed["targets"] == ["形成清晰可执行的内容主线。", "补齐可靠的数据说明。"]
- assert parsed["topicValue"] == "这是选题价值,不是目标。"
- assert parsed["accountValue"] == "这是账号价值。"
- assert parsed["targetCount"] == 2
- assert parsed["domainDimensionCount"] == 1
- assert parsed["constraintItems"] == [
- {"label": "通过标准", "value": "必须包含完整结构。", "group": "目标 1"}
- ]
- assert parsed["constraintGroups"] == [
- {
- "title": "目标 1",
- "kind": "target",
- "dimensionName": None,
- "items": [{"label": "通过标准", "value": "必须包含完整结构。"}],
- },
- {
- "title": "领域维度 1",
- "kind": "domain",
- "dimensionName": "行业事实准确性",
- "items": [],
- },
- ]
- def test_objective_parser_falls_back_without_inventing_a_summary():
- parsed = parse_objective_text("把产品机制解释清楚,并给出真实案例。")
- assert parsed["headline"] == "把产品机制解释清楚,并给出真实案例。"
- assert parsed["targets"] == []
- assert parsed["structured"] is False
- def test_goal_parser_keeps_the_complete_saved_goal_as_one_value():
- value = "补齐烹饪步骤。\n① 写清关键动作\n② 补充火候说明\n③ 加入避坑提示"
- parsed = parse_goal_text(value)
- assert parsed["headline"] == value
- assert parsed["focusItems"] == []
- assert parsed["raw"] == value
- assert "sections" not in parsed
- def test_goal_parser_does_not_infer_roles_from_sentence_keywords():
- value = (
- "立起脚本的段落骨架。"
- "竞争不同的框架切分与编排策略,选出整体最佳方案。"
- "本轮只做段落结构,不填充具体文案。"
- )
- parsed = parse_goal_text(value)
- assert parsed == {"headline": value, "focusItems": [], "raw": value}
- def test_single_path_is_business_single_even_when_raw_mode_is_divide():
- assert plan_mode_label("分工", 1) == "单路"
- assert plan_mode_label("竞争", 2) == "竞争"
- assert plan_path_summary(
- {"path_index": 2, "action": "增", "target": "烹饪步骤", "method": "补充细节"},
- 2,
- ) == "方案 2:新增 · 烹饪步骤 · 补充细节"
|