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 ifcpatch
import ifcopenshell import ifcopenshell
from pathlib import Path from pathlib import Path
from ifcpatch.recipes import Ifc2Sql
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc" TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
SQLITE_PATH = None SQLITE_PATH = None
@@ -29,13 +30,10 @@ def get_ifc_sqlite() -> ifcopenshell.sqlite:
global SQLITE_PATH global SQLITE_PATH
if SQLITE_PATH is None: if SQLITE_PATH is None:
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".ifcsqlite") tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".ifcsqlite")
ifcpatch.execute( ifc_file = ifcopenshell.open(TEST_FILE)
{ assert isinstance(ifc_file, ifcopenshell.file)
"file": ifcopenshell.open(TEST_FILE), patcher = Ifc2Sql.Patcher(ifc_file, database=tmp.name)
"recipe": "Ifc2Sql", patcher.patch()
"arguments": ["sqlite", None, None, None, tmp.name],
}
)
SQLITE_PATH = tmp.name SQLITE_PATH = tmp.name
ifc_sqlite = ifcopenshell.open(SQLITE_PATH) ifc_sqlite = ifcopenshell.open(SQLITE_PATH)
assert isinstance(ifc_sqlite, ifcopenshell.sqlite) assert isinstance(ifc_sqlite, ifcopenshell.sqlite)