feat: ExcelParser 基础(workbook/sheet 读取 + source_uri)

This commit is contained in:
lhl
2026-08-08 16:50:24 +08:00
parent 35d845fd21
commit df9427c76e
5 changed files with 68 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import pytest
from genesis.parsers.excel_reader import open_workbook, sheet_matrix
from genesis.parsers.provenance import build_source_uri
from tests.excel_helpers import new_workbook, save_workbook
def test_build_source_uri_format():
assert build_source_uri("要求.xlsx", "機能一覧", "A5") == "要求.xlsx#機能一覧!A5"
def test_open_workbook_and_sheet_matrix(tmp_path):
wb = new_workbook({"機能一覧": [["機能ID", "機能名"], ["F001", "社員登録"]]})
path = save_workbook(tmp_path, wb)
ws = open_workbook(path)["機能一覧"]
assert sheet_matrix(ws) == [["機能ID", "機能名"], ["F001", "社員登録"]]
def test_open_workbook_rejects_xls(tmp_path):
bad = tmp_path / "old.xls"
bad.write_bytes(b"not really xls")
with pytest.raises(ValueError):
open_workbook(bad)