feat(qa): add QAReport + QAValidator.validate_doc

This commit is contained in:
lhl
2026-08-13 11:05:01 +08:00
parent 48024a40db
commit b318c9fd41
3 changed files with 54 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
from genesis.qa.report import QAReport
from genesis.qa.validator import QAValidator
from genesis.writer.models import ChapterContent, ContentBlock
def _chapter(cid, text):
return ChapterContent(
chapter_id=cid, version=1, title=cid,
blocks=[ContentBlock(block_id="1", type="paragraph", text=text)],
)
def test_validate_doc_aggregates_qa_report():
v = QAValidator()
report = v.validate_doc(
[_chapter("a", "充分且规范的说明内容,满足写入规则要求。"), _chapter("b", "x")], None
)
assert isinstance(report, QAReport)
assert report.passed is False
assert "b" in report.failed_chapters
assert isinstance(report.overall_score, float)
assert len(report.per_chapter) == 2
assert "未通过" in report.summary