# -*- coding: utf-8 -*- """tests/docgen/test_intent_cases.py —— DC-INTENT-CASES-01~30(后端 pytest)。 唯一事实源:docs/team/cases_intent.md(30 条表,测试用副本 tests/docgen/cases_intent.md)。 数据文件:tests/docgen/data/intent_cases.json(由本文件从冻结表转写,转写后与 cases_intent.md 核对)。 执行:bash tests/docgen/run_all.sh intent(后端);前端同表双跑见 test_intent_frontend.mjs。 """ from __future__ import annotations import json from pathlib import Path import pytest DATA = Path(__file__).resolve().parent / "data" CASES = json.loads((DATA / "intent_cases.json").read_text(encoding="utf-8")) try: from app.services.docgen import intent as imod except ImportError: imod = None @pytest.mark.skipif(imod is None, reason="PENDING: app.services.docgen.intent 未交付") @pytest.mark.parametrize("case", CASES, ids=[f"#{c['num']}" for c in CASES]) def test_intent_case(case): route = getattr(imod, "route", None) or getattr(imod, "route_intent", None) assert route is not None got = route(case["text"], case["has_attachments"], case["has_active_artifact"]) assert got == case["expected"], f"#{case['num']} {case['text']!r} -> {got},期望 {case['expected']}"