Drawing_Extraction / test_exporting.py
ngohel58's picture
Upload 25 files
e425536 verified
Raw History Blame Contribute Delete
1.07 kB
import json
from pathlib import Path
from openpyxl import load_workbook
from drawing_intelligence.document import create_sample_drawing
from drawing_intelligence.exporting import create_export_files, records_to_dataframe
from drawing_intelligence.pipeline import run_extraction
def test_excel_and_json_exports_are_traceable(tmp_path: Path) -> None:
output = run_extraction(
create_sample_drawing(), model_key="demo", dpi=150, max_pages=1
)
table = records_to_dataframe(output.result.characteristics)
excel, json_file = create_export_files(table, output.result, tmp_path)
workbook = load_workbook(excel)
assert workbook.sheetnames == [
"Characteristics",
"Drawing metadata",
"General notes",
"Extraction log",
]
assert workbook["Characteristics"]["A2"].value == "1"
payload = json.loads(Path(json_file).read_text(encoding="utf-8"))
assert payload["source_name"] == "drawing_intelligence_sample.png"
assert len(payload["characteristics"]) == 6
assert "approval_notice" in payload