33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
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_chapter_passes_good():
|
|
v = QAValidator()
|
|
passed, report = v.validate_chapter(_chapter("a", "充分且规范的说明内容,满足写入规则要求。"), None)
|
|
assert passed is True
|
|
assert "a" not in report.failed_chapters
|
|
|
|
|
|
def test_validate_chapter_fails_short():
|
|
v = QAValidator()
|
|
passed, report = v.validate_chapter(_chapter("b", "x"), None)
|
|
assert passed is False
|
|
assert "b" in report.failed_chapters
|
|
|
|
|
|
def test_validate_document_aggregates():
|
|
v = QAValidator()
|
|
results = v.validate_document(
|
|
[_chapter("a", "充分且规范的说明内容,满足写入规则要求。"), _chapter("b", "x")], None
|
|
)
|
|
assert len(results) == 2
|
|
assert results[0][0] is True and results[1][0] is False
|