26 lines
759 B
Python
26 lines
759 B
Python
from pathlib import Path
|
|
|
|
import xlrd
|
|
|
|
from app.config import AppConfig
|
|
from app.excel_writer import XlsTemplateWriter
|
|
from app.pcf_parser import PcfParser
|
|
|
|
|
|
def test_write_sample_xls(tmp_path):
|
|
config = AppConfig.load()
|
|
parser = PcfParser(config)
|
|
files = list(Path("PCF文件样本(1)").glob("*.pcf"))
|
|
records, _candidates, _messages = parser.parse_files(files)
|
|
|
|
output = tmp_path / "result.xls"
|
|
XlsTemplateWriter(config).write(records, output)
|
|
|
|
book = xlrd.open_workbook(output)
|
|
sheet = book.sheet_by_name("Sheet1")
|
|
assert sheet.cell_value(0, 0) == "单位代码"
|
|
assert sheet.nrows >= 170
|
|
assert sheet.cell_value(1, 2)
|
|
assert sheet.cell_value(1, 3)
|
|
assert sheet.cell_value(1, 11) in {"安装", "预制"}
|