106 lines
3.8 KiB
Python
106 lines
3.8 KiB
Python
"""审校修订公开合同:基础检查、连续性发现与报告判定的确定性口径;不连数据库。"""
|
||
|
||
import pytest
|
||
|
||
from muse.审校修订.基础检查 import 判定必需通过, 运行基础检查
|
||
from muse.审校修订.接口 import 组装审校报告, 补齐报告身份
|
||
from muse.审校修订.模型 import 审校报告, 审校错误
|
||
from muse.审校修订.连续性审校 import 运行连续性审校
|
||
from muse.正文写作.模型 import 文本节点, 正文草稿, 段落
|
||
|
||
|
||
def 草稿(*文本: str) -> 正文草稿:
|
||
return 正文草稿(tuple(段落(f"p-{序}", (文本节点(段),)) for 序, 段 in enumerate(文本, start=1)))
|
||
|
||
|
||
细纲 = {
|
||
"targetChapter": 3,
|
||
"chapterGoal": "邮差在旧码头确认收信人。",
|
||
"hardConstraints": ["上一章结尾雨还没停。"],
|
||
"mustAppearEntities": ["lin-shen"],
|
||
"chapterEndHook": "仓库的门后有人应声。",
|
||
}
|
||
|
||
|
||
def test_空内容与空段结构失败且证据明确__a19b42():
|
||
报告 = 运行基础检查(草稿(" "))
|
||
项 = {c.名称: c for c in 报告.检查}
|
||
assert 报告.判定 == "failed"
|
||
assert 项["空内容"].判定 == "failed"
|
||
assert 项["结构"].判定 == "failed"
|
||
|
||
|
||
def test_末段无收束判截断合法收束不误报__b28c53():
|
||
截断 = 运行基础检查(草稿("林深走到跳板尽头,忽然停住"))
|
||
assert {c.名称: c for c in 截断.检查}["截断"].判定 == "failed"
|
||
收束 = 运行基础检查(草稿("林深把信递了过去。"))
|
||
assert {c.名称: c for c in 收束.检查}["截断"].判定 == "passed"
|
||
|
||
|
||
def test_原始交付损坏判输出有效性失败__c39d64():
|
||
好 = 运行基础检查(草稿("他收好信。"), 原始交付='{"paragraphs":[]}')
|
||
坏 = 运行基础检查(草稿("他收好信。"), 原始交付="{not-json")
|
||
assert {c.名称: c for c in 好.检查}["输出有效性"].判定 == "passed"
|
||
assert {c.名称: c for c in 坏.检查}["输出有效性"].判定 == "failed"
|
||
assert not 判定必需通过(坏)
|
||
|
||
|
||
def test_必出场缺失与复读细纲措辞均为冲突级发现__d4ae75():
|
||
发现 = 运行连续性审校(
|
||
"林深把信压在掌心。上一章结尾雨还没停,他没有回头。",
|
||
细纲,
|
||
{"lin-shen": "林深"},
|
||
依据快照="snap-1",
|
||
).findings
|
||
类别 = [(f.类别, f.判定) for f in 发现]
|
||
assert ("引文", "conflict") in 类别
|
||
泄漏 = [f for f in 发现 if "复读" in f.说明]
|
||
assert 泄漏 and 泄漏[0].证据["leaked_phrase"]
|
||
|
||
|
||
def test_出场齐全且不复读时无发现并记录覆盖__e5bf86():
|
||
报告 = 运行连续性审校(
|
||
"雨点敲着铁皮屋顶,林深把退回的信压在掌心,沿跳板走向仓库。",
|
||
细纲,
|
||
{"lin-shen": "林深"},
|
||
依据快照="snap-1",
|
||
)
|
||
assert 报告.findings == ()
|
||
assert 报告.coverage["依据快照"] == "snap-1"
|
||
assert 报告.coverage["规则版本"].startswith("w15")
|
||
|
||
|
||
def test_报告总判定与基础及冲突发现一致且绑定版本__f6c097():
|
||
好报告 = 组装审校报告(
|
||
草稿("林深沿跳板走向仓库,把信递了过去。"),
|
||
细纲,
|
||
{"lin-shen": "林深"},
|
||
candidate_id="c-1",
|
||
candidate_revision=1,
|
||
snapshot_id="snap-1",
|
||
)
|
||
assert 好报告.verdict == "passed"
|
||
带身份 = 补齐报告身份(好报告)
|
||
assert 带身份.report_id
|
||
|
||
坏报告 = 组装审校报告(
|
||
草稿("上一章结尾雨还没停,他停住"),
|
||
细纲,
|
||
{"lin-shen": "林深"},
|
||
candidate_id="c-2",
|
||
candidate_revision=1,
|
||
snapshot_id="snap-1",
|
||
)
|
||
assert 坏报告.verdict == "failed"
|
||
|
||
with pytest.raises(审校错误):
|
||
审校报告(
|
||
"r-x",
|
||
"c-3",
|
||
1,
|
||
"snap-1",
|
||
好报告.basic,
|
||
坏报告.continuity,
|
||
"passed",
|
||
)
|