Repository navigation
Expand file tree
/
Copy pathtest_ifcopenshell_python_shared_libraries.py
More file actions
127 lines (106 loc) · 4.58 KB
/
Copy pathtest_ifcopenshell_python_shared_libraries.py
File metadata and controls
127 lines (106 loc) · 4.58 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""Package tests that fail when a packaged shared library can't be loaded.
Plug-ins are loaded at runtime, so a missing library only shows up when its plug-in
is loaded, and often as a "missing plug-in" error. These tests load every plug-in.
Not covered currently - local dependencies, e.g.:
- locally installed dependencies (system copies of libraries missing from the package)
- dependencies on build artifacts (absolute install names or rpaths into the build tree)
"""
import os
from pathlib import Path
import ifcopenshell
import ifcopenshell.geom
import pytest
PACKAGE_DIR = Path(ifcopenshell.__file__).parent
CONDA = "CONDA_PREFIX" in os.environ
SKIP_ON_CONDA = pytest.mark.skipif(CONDA, reason="plug-in is not registered in the conda package")
@pytest.mark.parametrize(
"schema",
[
pytest.param("IFC2X3", id="ifcopenshell_parse_schema_ifc2x3"),
pytest.param("IFC4", id="ifcopenshell_parse_schema_ifc4"),
pytest.param("IFC4X3_ADD2", id="ifcopenshell_parse_schema_ifc4x3_add2"),
],
)
def test_schema_loads(schema: str):
ifcopenshell.schema_by_name(schema)
@pytest.mark.parametrize(
"schema",
[
pytest.param("IFC2X3", id="ifcopenshell_geometry_mapping_ifc2x3"),
pytest.param("IFC4", id="ifcopenshell_geometry_mapping_ifc4"),
pytest.param("IFC4X3_ADD2", id="ifcopenshell_geometry_mapping_ifc4x3_add2"),
],
)
def test_geometry_mapping_loads(schema: str):
ifcopenshell.geom.kernel(ifcopenshell.geom.settings(), ifcopenshell.file(schema=schema), "passthrough")
@pytest.mark.parametrize(
"kernel",
[
pytest.param("opencascade", id="ifcopenshell_geometry_kernel_opencascade"),
pytest.param("cgal", id="ifcopenshell_geometry_kernel_cgal"),
pytest.param("cgal-simple", id="ifcopenshell_geometry_kernel_cgalsimple"),
pytest.param("manifold", id="ifcopenshell_geometry_kernel_manifold", marks=SKIP_ON_CONDA),
pytest.param("passthrough", id="ifcopenshell_geometry_kernel_passthrough"),
],
)
def test_geometry_kernel_loads(kernel: str):
assert ifcopenshell.geom.has_geometry_library(kernel)
@pytest.mark.parametrize(
"extension",
[
pytest.param("dae", id="ifcopenshell_geometry_dae", marks=SKIP_ON_CONDA),
pytest.param("glb", id="ifcopenshell_geometry_glb"),
pytest.param("igs", id="ifcopenshell_geometry_igs"),
pytest.param("obj", id="ifcopenshell_geometry_obj"),
pytest.param("stp", id="ifcopenshell_geometry_stp"),
pytest.param("svg", id="ifcopenshell_geometry_svg"),
pytest.param("ttl", id="ifcopenshell_geometry_ttl"),
],
)
def test_geometry_serializer_loads(extension: str, tmp_path: Path):
serializer = getattr(ifcopenshell.geom.serializers, extension)
serializer(str(tmp_path / f"model.{extension}"), ifcopenshell.geom.settings())
@pytest.mark.parametrize([], [pytest.param(id="ifcopenshell_geometry_svgfill")])
def test_svgfill_loads():
svg = '<svg xmlns="http://www.w3.org/2000/svg"><g class="projection"><path d="M 0,0 L 1,0"/></g></svg>'
assert ifcopenshell.ifcopenshell_wrapper.svg_to_line_segments(svg, "projection")
@pytest.mark.parametrize(
"backend",
[
pytest.param("opencascade.brep", id="ifcopenshell_geometry_tree_opencascade_brep"),
pytest.param("opencascade.trianglebvh", id="ifcopenshell_geometry_tree_opencascade_trianglebvh"),
],
)
def test_geometry_tree_loads(backend: str):
ifcopenshell.geom.tree(backend=backend)
@pytest.mark.parametrize([], [pytest.param(id="ifcopenshell_document_rdb", marks=SKIP_ON_CONDA)])
def test_document_rdb_loads(tmp_path: Path):
ifc_path = tmp_path / "model.ifc"
ifcopenshell.file().write(ifc_path)
rdb_path = tmp_path / "model.rdb"
ifcopenshell.convert_path_to_rocksdb(ifc_path, rdb_path)
assert rdb_path.exists()
def test_every_plugin_is_tested(request: pytest.FixtureRequest):
if request.config.getoption("not_bundled"):
pytest.skip("plug-ins are not installed next to the package")
tested = {
param.id
for test in list(globals().values())
for mark in getattr(test, "pytestmark", [])
if mark.name == "parametrize"
for param in mark.args[1]
}
packaged = {
path.name.split(".")[0]
for path in PACKAGE_DIR.iterdir()
if path.name.startswith("ifcopenshell_")
and path.suffix in (".so", ".dylib", ".dll")
and path.name.split(".")[0]
not in {
"ifcopenshell_parse",
"ifcopenshell_geometry",
"ifcopenshell_geometry_writer",
"ifcopenshell_plugin",
}
}
assert packaged == tested