fix(application-form-fill): 清理填表说明并收窄按钮话术
This commit is contained in:
@@ -41,6 +41,17 @@ def _template(path):
|
||||
document.save(path)
|
||||
|
||||
|
||||
def _template_with_instructions(path):
|
||||
document = Document()
|
||||
table = document.add_table(rows=2, cols=2)
|
||||
table.rows[0].cells[0].text = "产品名称"
|
||||
table.rows[1].cells[0].text = "预期用途"
|
||||
document.add_paragraph("填表说明")
|
||||
document.add_paragraph("1. 本表依据《体外诊断注册与备案管理办法》制定。")
|
||||
document.add_paragraph("2. 本表可从国家药品监督管理局网站下载。")
|
||||
document.save(path)
|
||||
|
||||
|
||||
def test_word_fill_writes_table_rows(tmp_path):
|
||||
template_path = tmp_path / "template.docx"
|
||||
output_path = tmp_path / "filled.docx"
|
||||
@@ -61,6 +72,27 @@ def test_word_fill_writes_table_rows(tmp_path):
|
||||
assert document.tables[0].rows[1].cells[1].text == "用于体外检测"
|
||||
|
||||
|
||||
def test_word_fill_removes_template_fill_instructions(tmp_path):
|
||||
template_path = tmp_path / "template.docx"
|
||||
output_path = tmp_path / "filled.docx"
|
||||
_template_with_instructions(template_path)
|
||||
|
||||
fill_template(
|
||||
template_path,
|
||||
output_path,
|
||||
_spec(),
|
||||
{
|
||||
"product_name": MergedField("product_name", "产品名称", "甲胎蛋白检测试剂盒", "说明书.txt", "证据", 0.8),
|
||||
},
|
||||
)
|
||||
|
||||
document = Document(output_path)
|
||||
text = "\n".join(paragraph.text for paragraph in document.paragraphs)
|
||||
assert "填表说明" not in text
|
||||
assert "本表依据" not in text
|
||||
assert document.tables[0].rows[0].cells[1].text == "甲胎蛋白检测试剂盒"
|
||||
|
||||
|
||||
def test_word_fill_highlights_conflict_in_docx_xml(tmp_path):
|
||||
template_path = tmp_path / "template.docx"
|
||||
output_path = tmp_path / "filled.docx"
|
||||
|
||||
Reference in New Issue
Block a user