test_main_decision_text.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. from app.main_decision_text import (
  2. parse_goal_text,
  3. parse_objective_text,
  4. plan_mode_label,
  5. plan_path_summary,
  6. )
  7. def test_objective_parser_prefers_real_target_statement_over_value_proposition():
  8. value = """## 选题价值主张
  9. 这是选题价值,不是目标。
  10. ## 账号价值主张
  11. 这是账号价值。
  12. ## 创作总目标
  13. ### 目标 1
  14. - 目标语句:形成清晰可执行的内容主线。
  15. - 通过标准:必须包含完整结构。
  16. ### 目标 2
  17. - 目标语句:补齐可靠的数据说明。
  18. ## 领域评估维度
  19. ### 领域维度 1
  20. - name:行业事实准确性
  21. """
  22. parsed = parse_objective_text(value)
  23. assert parsed["headline"] == "形成清晰可执行的内容主线。"
  24. assert parsed["targets"] == ["形成清晰可执行的内容主线。", "补齐可靠的数据说明。"]
  25. assert parsed["topicValue"] == "这是选题价值,不是目标。"
  26. assert parsed["accountValue"] == "这是账号价值。"
  27. assert parsed["targetCount"] == 2
  28. assert parsed["domainDimensionCount"] == 1
  29. assert parsed["constraintItems"] == [
  30. {"label": "通过标准", "value": "必须包含完整结构。", "group": "目标 1"}
  31. ]
  32. assert parsed["constraintGroups"] == [
  33. {
  34. "title": "目标 1",
  35. "kind": "target",
  36. "dimensionName": None,
  37. "items": [{"label": "通过标准", "value": "必须包含完整结构。"}],
  38. },
  39. {
  40. "title": "领域维度 1",
  41. "kind": "domain",
  42. "dimensionName": "行业事实准确性",
  43. "items": [],
  44. },
  45. ]
  46. def test_objective_parser_falls_back_without_inventing_a_summary():
  47. parsed = parse_objective_text("把产品机制解释清楚,并给出真实案例。")
  48. assert parsed["headline"] == "把产品机制解释清楚,并给出真实案例。"
  49. assert parsed["targets"] == []
  50. assert parsed["structured"] is False
  51. def test_goal_parser_keeps_the_complete_saved_goal_as_one_value():
  52. value = "补齐烹饪步骤。\n① 写清关键动作\n② 补充火候说明\n③ 加入避坑提示"
  53. parsed = parse_goal_text(value)
  54. assert parsed["headline"] == value
  55. assert parsed["focusItems"] == []
  56. assert parsed["raw"] == value
  57. assert "sections" not in parsed
  58. def test_goal_parser_does_not_infer_roles_from_sentence_keywords():
  59. value = (
  60. "立起脚本的段落骨架。"
  61. "竞争不同的框架切分与编排策略,选出整体最佳方案。"
  62. "本轮只做段落结构,不填充具体文案。"
  63. )
  64. parsed = parse_goal_text(value)
  65. assert parsed == {"headline": value, "focusItems": [], "raw": value}
  66. def test_single_path_is_business_single_even_when_raw_mode_is_divide():
  67. assert plan_mode_label("分工", 1) == "单路"
  68. assert plan_mode_label("竞争", 2) == "竞争"
  69. assert plan_path_summary(
  70. {"path_index": 2, "action": "增", "target": "烹饪步骤", "method": "补充细节"},
  71. 2,
  72. ) == "方案 2:新增 · 烹饪步骤 · 补充细节"