- 门控:用户提供 existing_system 路径 → 进入影响调查;未提供 → 原流程不变
- CodeParser 解析 Java(@RestController/@Service/@Entity/@TableName)+ ExistingSystemExplorer 组装
- ImpactAgent 变更点定位(变更区分×既存対応 确定性比对,无 LLM)→ ImpactReport(JSON 可下载)
- 影响调查结果作为 Writer 生成概要设计书的主上下文({{impact}},无专用影响章)
- source_aggregator 解除 existing_system=None 硬编码
- 既有系统样本 sunOnly/stock-trade-system(无 LICENSE,仅测试输入,保留来源标注)
- 新造股票交易域追加改修样本 要件定義_追加改修_股票.xlsx(对齐 sunOnly 真实类名)
- 全量 351 passed / 99.27% 覆盖;门禁 PASS(16 要素:新规5/変更8/削除3/未受影响50)
85 lines
3.5 KiB
Python
85 lines
3.5 KiB
Python
from genesis.writer.models import ContentBlock, ChapterContent, GenerationContext, ChapterSpec
|
|
|
|
|
|
def test_content_block_defaults():
|
|
b = ContentBlock(block_id="b1", type="paragraph", text="你好")
|
|
assert b.level is None
|
|
assert b.source_uris == []
|
|
|
|
|
|
def test_chapter_content_holds_blocks():
|
|
b = ContentBlock(block_id="b1", type="heading", level=2, text="标题")
|
|
c = ChapterContent(chapter_id="db_design", version=1, title="DB 设计", blocks=[b])
|
|
assert c.blocks[0].type == "heading"
|
|
assert c.version == 1
|
|
|
|
|
|
def test_generation_context_impact_field_default_none():
|
|
ctx = GenerationContext(
|
|
chapter_id="db_design", title="DB 设计",
|
|
template_marker=ChapterSpec(chapter_id="db_design", title="DB 设计", section_placeholder="{{section:db_design}}"),
|
|
structured_source=None, write_rules=["规则1"], design_rules=["规则2"],
|
|
template_styles={"Heading 1"},
|
|
)
|
|
assert ctx.impact_report is None
|
|
# to_vars 始终提供 impact 变量;无影响调查书时为空串
|
|
assert ctx.to_vars()["impact"] == ""
|
|
|
|
|
|
def test_generation_context_impact_var_formats_report():
|
|
from genesis.data_models import ChangeAnalysis, ChangeElement, ChangeType, ImpactReport
|
|
ca = ChangeAnalysis(
|
|
project_type="enhancement",
|
|
new_elements=[ChangeElement("F001", "機能", "止损风控", ChangeType.NEW)],
|
|
modified_elements=[],
|
|
deleted_elements=[],
|
|
unchanged_elements=[],
|
|
warnings=[],
|
|
)
|
|
report = ImpactReport(metadata={"version": "v1"}, change_analysis=ca, summary={"new": 1})
|
|
ctx = GenerationContext(
|
|
chapter_id="db_design", title="DB 设计",
|
|
template_marker=ChapterSpec(chapter_id="db_design", title="DB 设计", section_placeholder="{{section:db_design}}"),
|
|
structured_source=None, write_rules=["规则1"], design_rules=["规则2"],
|
|
template_styles={"Heading 1"}, impact_report=report,
|
|
)
|
|
impact = ctx.to_vars()["impact"]
|
|
assert "止损风控" in impact
|
|
assert "F001" in impact
|
|
|
|
|
|
def _impact_ctx(report):
|
|
return GenerationContext(
|
|
chapter_id="db_design", title="DB 设计",
|
|
template_marker=ChapterSpec(chapter_id="db_design", title="DB 设计", section_placeholder="{{section:db_design}}"),
|
|
structured_source=None, write_rules=[], design_rules=[],
|
|
template_styles=set(), impact_report=report,
|
|
)
|
|
|
|
|
|
def test_impact_var_empty_when_report_without_analysis():
|
|
from genesis.data_models import ImpactReport
|
|
report = ImpactReport(metadata={"version": "v1"}, change_analysis=None, summary={})
|
|
assert _impact_ctx(report).to_vars()["impact"] == ""
|
|
|
|
|
|
def test_impact_var_formats_deleted_and_warnings():
|
|
from genesis.data_models import ChangeAnalysis, ChangeElement, ChangeType, ImpactReport, ImpactWarning
|
|
ca = ChangeAnalysis(
|
|
project_type="enhancement",
|
|
new_elements=[],
|
|
modified_elements=[],
|
|
deleted_elements=[ChangeElement("F030", "機能", "旧功能", ChangeType.DELETED)],
|
|
unchanged_elements=[],
|
|
warnings=[ImpactWarning("F030", "缺少既存対応")],
|
|
)
|
|
report = ImpactReport(metadata={}, change_analysis=ca, summary={"deleted": 1, "warnings": 1})
|
|
impact = _impact_ctx(report).to_vars()["impact"]
|
|
assert "[削除]" in impact and "旧功能" in impact
|
|
assert "[警告]" in impact and "缺少既存対応" in impact
|
|
|
|
|
|
def test_chapter_spec_placeholder_optional():
|
|
s = ChapterSpec(chapter_id="x", title="X", section_placeholder=None)
|
|
assert s.section_placeholder is None
|