test(writer/qa): 覆盖 engine=None 委托工厂的真实门禁路径

This commit is contained in:
lhl
2026-08-13 23:13:58 +08:00
parent 2cd3ecd0f3
commit 24b9511d43
3 changed files with 27 additions and 1 deletions
+2 -1
View File
@@ -104,4 +104,5 @@
| 2026-08-13 | 测试验证 | Phase5 T15 端到端 e2e + DocxInjector 真实接口对齐(inject/sections | tests/test_phase5_e2e.py; src/genesis/writer/docx_injector.py | gstack-subagent |
| 2026-08-13 | 文档规范 | Phase5 T16 design.md 追加 Phase 5 Writer/QA 子系统章节 + 日志补齐 | docs/design.md; _AI_USAGE_LOG.md | gstack-subagent |
| 2026-08-13 23:11 | Agent 实现 | 接通真实 LLM 引擎工厂(P5-T10 门禁接线):新增 inference/factory.pyorchestrator/qa_loop 接入,脚本校验适配,补工厂测试 | src/genesis/inference/factory.py; src/genesis/writer/orchestrator.py; src/genesis/qa/qa_loop.py; scripts/run_phase5_slice.py; tests/test_inference_factory.py | hy3-free |
| 2026-08-13 23:11 | Agent 实现 | 接通真实 LLM 引擎工厂(P5-T10 门禁接线):新增 inference/factory.pyorchestrator/qa_loop 接入,脚本校验适配,补工厂测试 | src/genesis/inference/factory.py; src/genesis/writer/orchestrator.py; src/genesis/qa/qa_loop.py; scripts/run_phase5_slice.py; tests/test_inference_factory.py | hy3-free |
| 2026-08-13 23:20 | 测试验证 | P5-T10 引擎工厂接线:补 engine=None 委托工厂测试(orchestrator/qa_loop),全量 296 passed / 99.04% | tests/test_phase5_writer_orchestrator.py; tests/test_phase5_qa_loop.py | hy3-free |
+11
View File
@@ -54,3 +54,14 @@ def test_qa_loop_regenerates_only_failed(tmp_path):
assert report.passed is True
assert engine.calls["A"] == 1 # A 首次即通过,未被重生成
assert engine.calls["B"] == 2 # B 失败后被重生成一次
def test_run_delegates_to_factory_when_engine_none(monkeypatch, tmp_path):
# 门禁真实路径:engine=None 时应委托 build_inference_engine() 构造真实引擎
monkeypatch.setattr("genesis.qa.qa_loop.build_inference_engine", lambda: ImprovingEngine())
tpl = tmp_path / "tpl.docx"
out = tmp_path / "out.docx"
_make_template(str(tpl))
loop = QALoop(max_rounds=3)
report = loop.run(_ss(str(tpl)), str(out), samples_dir="nonexistent_dir_xyz", engine=None)
assert report.passed is True
+14
View File
@@ -69,3 +69,17 @@ def test_generate_with_async_engine_produces_filled_docx(tmp_path):
loaded = Document(str(out))
joined = "\n".join(p.text for p in loaded.paragraphs)
assert "异步引擎内容" in joined
def test_generate_delegates_to_factory_when_engine_none(monkeypatch, tmp_path):
# 门禁真实路径:engine=None 时应委托 build_inference_engine() 构造真实引擎
monkeypatch.setattr("genesis.writer.orchestrator.build_inference_engine", lambda: FakeEngine())
tpl = tmp_path / "tpl.docx"
out = tmp_path / "out.docx"
_make_template(str(tpl))
contents = WriteOrchestrator().generate(
_ss(str(tpl)), str(out), samples_dir="nonexistent_dir_xyz", engine=None
)
assert len(contents) == 1
loaded = Document(str(out))
assert "自动生成的内容" in "\n".join(p.text for p in loaded.paragraphs)