fix: 遗留清理(枚举同源/边界防御/断言补强)

This commit is contained in:
lhl
2026-08-09 04:18:39 +08:00
parent 75925168c7
commit d93cc77bae
9 changed files with 59 additions and 11 deletions
+14 -2
View File
@@ -1,4 +1,4 @@
from genesis.data_models import CellValue, ExcelTable, SheetType
from genesis.data_models import CellValue, ExcelTable, ExtractionMethod, SheetType
from genesis.parsers.merge_fill import forward_fill
from genesis.parsers.table_extractor import column_letter, extract_table
@@ -37,4 +37,16 @@ def test_extract_table_basic():
assert isinstance(first["ID"], CellValue)
assert first["ID"].value == "1"
assert first["ID"].provenance.sheet_name == "社員一覧"
assert first["ID"].provenance.column == "A"
assert first["ID"].provenance.column == "A"
def test_extract_table_uses_enum_value():
matrix = [["ID"], ["1"]]
table = extract_table("社員", matrix, "f.xlsx", SheetType.FUNCTION)
assert table.extraction_method == ExtractionMethod.OPENPYXL.value
def test_forward_fill_ignores_invalid_range():
matrix = [["A"], ["B"]]
assert forward_fill(matrix, [(0, 1, 2, 1)]) == matrix # min_row=0 非法 → 不崩溃不改数据
assert forward_fill(matrix, [(9, 9, 9, 9)]) == matrix # 越界 → 不崩溃