Spaces:
Runtime error
Runtime error
File size: 1,072 Bytes
e425536 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 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
|