| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- from __future__ import annotations
- from decimal import Decimal
- from fastapi.testclient import TestClient
- from finrep_algo_agent.config import Settings, get_settings
- from finrep_algo_agent.main import app
- from finrep_algo_agent.schemas.outline import (
- ChapterCandidate,
- ChapterL1Result,
- OutlineL1Request,
- OutlineL1Response,
- )
- def test_outline_l2_batch_stub_mixed_s1_s2() -> None:
- def _stub_settings() -> Settings:
- return Settings(stub_skills=True)
- app.dependency_overrides[get_settings] = _stub_settings
- try:
- client = TestClient(app)
- l1_req = OutlineL1Request(
- report_type="项目融资",
- agreement_amount=Decimal("40"),
- chapter_candidates=[
- ChapterCandidate(chapter_id="a1", chapter_name="章A"),
- ChapterCandidate(chapter_id="a2", chapter_name="章B"),
- ],
- )
- l1_resp = OutlineL1Response(
- chapter_results=[
- ChapterL1Result(
- chapter_id="a1",
- chapter_name="章A",
- presentation_enum="S2",
- paragraph_count_enum="P0",
- reason="不呈现",
- ),
- ChapterL1Result(
- chapter_id="a2",
- chapter_name="章B",
- presentation_enum="S1",
- paragraph_count_enum="P2",
- reason="呈现",
- ),
- ],
- overall_logic="总逻辑占位",
- )
- r = client.post(
- "/v1/outline/l2/batch",
- json={
- "l1_task_snapshot": l1_req.model_dump(mode="json"),
- "l1_response": l1_resp.model_dump(mode="json"),
- },
- )
- assert r.status_code == 200, r.text
- body = r.json()
- assert body["overall_logic"] == "总逻辑占位"
- assert len(body["chapters"]) == 2
- assert body["chapters"][0]["chapter_id"] == "a1"
- assert body["chapters"][0]["l2"]["chapter_structure"] == []
- assert body["chapters"][1]["chapter_id"] == "a2"
- assert body["chapters"][1]["l2"]["chapter_structure"]
- finally:
- app.dependency_overrides.clear()
|