feat: 实现模板解析,自动识别 {{占位符}}

This commit is contained in:
MikiVL
2026-05-05 05:52:42 +08:00
parent 18de4f9f47
commit 1f51665e42
4 changed files with 62 additions and 2 deletions
+28 -1
View File
@@ -1 +1,28 @@
# placeholder
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../python"))
from parser import parse_template
FIXTURE = os.path.join(os.path.dirname(__file__), "../fixtures/sample_template.xlsx")
def test_returns_sheets():
result = parse_template(FIXTURE)
assert "sheets" in result
assert "Sheet1" in result["sheets"]
def test_detects_placeholders():
result = parse_template(FIXTURE)
names = [p["name"] for p in result["placeholders"]]
assert "编号" in names
assert "姓名" in names
def test_ignores_non_placeholders():
result = parse_template(FIXTURE)
names = [p["name"] for p in result["placeholders"]]
assert "normal_value" not in names
def test_placeholder_has_cell_info():
result = parse_template(FIXTURE)
biaohao = next(p for p in result["placeholders"] if p["name"] == "编号")
assert biaohao["sheet"] == "Sheet1"
assert biaohao["cell"] == "B3"