feat: FormattingDetector(取消线/背景色/批注)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from copy import copy
|
||||
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.comments import Comment
|
||||
|
||||
from genesis.data_models import CellComment, CellFormatting
|
||||
from genesis.parsers.formatting_detector import (
|
||||
cell_comment, cell_formatting, collect_comments,
|
||||
)
|
||||
|
||||
|
||||
def make_wb():
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "機能一覧"
|
||||
ws["A1"] = "F001"
|
||||
font = copy(ws["A1"].font)
|
||||
font.strike = True
|
||||
ws["A1"].font = font
|
||||
ws["A2"] = "F002"
|
||||
ws["A2"].comment = Comment("要確認", "reviewer")
|
||||
return wb
|
||||
|
||||
|
||||
def test_cell_formatting_detects_strike():
|
||||
fmt = cell_formatting(make_wb().active["A1"])
|
||||
assert fmt is not None
|
||||
assert fmt.strikethrough is True
|
||||
|
||||
|
||||
def test_cell_formatting_none_when_plain():
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws["A1"] = "x"
|
||||
assert cell_formatting(ws["A1"]) is None
|
||||
|
||||
|
||||
def test_cell_comment_returns_obj():
|
||||
wb = make_wb()
|
||||
cm = cell_comment(wb.active["A2"], "f.xlsx")
|
||||
assert isinstance(cm, CellComment)
|
||||
assert cm.author == "reviewer"
|
||||
assert cm.text == "要確認"
|
||||
assert cm.source_uri == "f.xlsx#機能一覧!A2"
|
||||
|
||||
|
||||
def test_collect_comments():
|
||||
comments = collect_comments(make_wb().active, "f.xlsx")
|
||||
assert len(comments) == 1
|
||||
Reference in New Issue
Block a user