feat: MergeHandler + TableExtractor(forward_fill / 表格提取)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from genesis.data_models import CellValue, ExcelTable, SheetType
|
||||
from genesis.parsers.merge_fill import forward_fill
|
||||
from genesis.parsers.table_extractor import column_letter, extract_table
|
||||
|
||||
|
||||
def test_forward_fill_vertical():
|
||||
matrix = [
|
||||
["機能ID", "機能名", "備考"],
|
||||
["A001", "", ""],
|
||||
["", "", "メモ"],
|
||||
]
|
||||
filled = forward_fill(matrix, [(1, 2, 2, 2)]) # B1:B2 纵向合并
|
||||
assert filled[1][1] == "機能名"
|
||||
assert filled[2][2] == "メモ"
|
||||
|
||||
|
||||
def test_forward_fill_horizontal():
|
||||
matrix = [["A", "B"], ["x", ""]]
|
||||
filled = forward_fill(matrix, [(2, 1, 2, 2)]) # A2:B2 横向合并
|
||||
assert filled[1][1] == "x"
|
||||
assert filled[1][0] == "x"
|
||||
|
||||
|
||||
def test_column_letter():
|
||||
assert column_letter(1) == "A"
|
||||
assert column_letter(27) == "AA"
|
||||
|
||||
|
||||
def test_extract_table_basic():
|
||||
matrix = [["ID", "名前"], ["1", "田中"], ["2", "佐藤"]]
|
||||
table = extract_table("社員一覧", matrix, "f.xlsx", SheetType.FUNCTION)
|
||||
assert isinstance(table, ExcelTable)
|
||||
assert table.headers == ["ID", "名前"]
|
||||
assert table.extraction_method == "openpyxl"
|
||||
assert len(table.rows) == 2
|
||||
first = table.rows[0]
|
||||
assert isinstance(first["ID"], CellValue)
|
||||
assert first["ID"].value == "1"
|
||||
assert first["ID"].provenance.sheet_name == "社員一覧"
|
||||
assert first["ID"].provenance.column == "A"
|
||||
Reference in New Issue
Block a user