fix: 遗留清理(枚举同源/边界防御/断言补强)
This commit is contained in:
@@ -35,6 +35,19 @@ def test_cell_formatting_none_when_plain():
|
||||
assert cell_formatting(ws["A1"]) is None
|
||||
|
||||
|
||||
def test_cell_formatting_detects_font_color():
|
||||
from openpyxl.styles import Font
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws["A1"] = "x"
|
||||
f = copy(ws["A1"].font)
|
||||
f.color = Font(color="FF0000FF").color
|
||||
ws["A1"].font = f
|
||||
fmt = cell_formatting(ws["A1"])
|
||||
assert fmt is not None
|
||||
assert fmt.font_color is not None
|
||||
|
||||
|
||||
def test_cell_comment_returns_obj():
|
||||
wb = make_wb()
|
||||
cm = cell_comment(wb.active["A2"], "f.xlsx")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from genesis.data_models import CellValue, ExcelTable, SheetType
|
||||
from genesis.data_models import CellValue, ExcelTable, ExtractionMethod, SheetType
|
||||
from genesis.parsers.free_text_extractor import build_free_text_table, extract_text_blocks
|
||||
|
||||
|
||||
@@ -15,3 +15,8 @@ def test_build_free_text_table():
|
||||
assert len(table.rows) == 2
|
||||
assert isinstance(table.rows[0]["text"], CellValue)
|
||||
assert table.rows[0]["text"].value == "A"
|
||||
|
||||
|
||||
def test_free_text_uses_enum_value():
|
||||
table = build_free_text_table("メモ", ["A"], "f.xlsx")
|
||||
assert table.extraction_method == ExtractionMethod.LLM_FROM_FREE_TEXT.value
|
||||
|
||||
@@ -19,4 +19,14 @@ def test_free_text_many_empty_rows():
|
||||
def test_header_row_index():
|
||||
m = [["機能ID", "名前"], ["1", "田中"]]
|
||||
assert find_header_row(m) == 0
|
||||
assert find_header_row([["自由テキスト"]]) == -1
|
||||
assert find_header_row([["自由テキスト"]]) == -1
|
||||
|
||||
|
||||
def test_classify_sheet_mixed_with_bullet_line():
|
||||
m = [["ID", "名前"], ["1", "田中"], ["・備考行"]]
|
||||
assert classify_sheet(m) == SheetNature.MIXED
|
||||
|
||||
|
||||
def test_classify_sheet_mixed_with_square_line():
|
||||
m = [["ID", "名前"], ["1", "田中"], ["■備考行"]]
|
||||
assert classify_sheet(m) == SheetNature.MIXED
|
||||
@@ -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 # 越界 → 不崩溃
|
||||
Reference in New Issue
Block a user