test_sql - use Ifc2Sql patcher for readability

This commit is contained in:
Andrej
2025-06-05 18:38:31 +05:00
parent d6b5c73d4a
commit fc0624692f
+5 -7
View File
@@ -20,6 +20,7 @@ import tempfile
import ifcpatch
import ifcopenshell
from pathlib import Path
from ifcpatch.recipes import Ifc2Sql
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
SQLITE_PATH = None
@@ -29,13 +30,10 @@ def get_ifc_sqlite() -> ifcopenshell.sqlite:
global SQLITE_PATH
if SQLITE_PATH is None:
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".ifcsqlite")
ifcpatch.execute(
{
"file": ifcopenshell.open(TEST_FILE),
"recipe": "Ifc2Sql",
"arguments": ["sqlite", None, None, None, tmp.name],
}
)
ifc_file = ifcopenshell.open(TEST_FILE)
assert isinstance(ifc_file, ifcopenshell.file)
patcher = Ifc2Sql.Patcher(ifc_file, database=tmp.name)
patcher.patch()
SQLITE_PATH = tmp.name
ifc_sqlite = ifcopenshell.open(SQLITE_PATH)
assert isinstance(ifc_sqlite, ifcopenshell.sqlite)