Skip to content

Commit ff3d8d8

Browse files
fix: broken interactive docs and improved tests paths (#1244)
Co-authored-by: pyansys-ci-bot <pyansys.github.bot@ansys.com>
1 parent 95bc043 commit ff3d8d8

File tree

8 files changed

+64
-60
lines changed

8 files changed

+64
-60
lines changed

doc/changelog.d/1244.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix: broken interactive docs and improved tests paths

doc/source/conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pathlib import Path
77
import time
88

9-
import ansys.tools.visualization_interface as viz_interface
109
from ansys_sphinx_theme import (
1110
ansys_favicon,
1211
ansys_logo_white,
@@ -22,7 +21,13 @@
2221

2322
from ansys.geometry.core import __version__
2423

25-
viz_interface.DOCUMENTATION_BUILD = True
24+
# For some reason the global var is not working on doc build...
25+
# import ansys.tools.visualization_interface as viz_interface
26+
#
27+
# viz_interface.DOCUMENTATION_BUILD = True
28+
#
29+
# Using env var instead
30+
os.environ["PYANSYS_VISUALIZER_DOC_MODE"] = "true"
2631

2732
LaTeXBuilder.supported_image_types = ["image/png", "image/pdf", "image/svg+xml"]
2833

tests/integration/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
viz_interface.TESTING_MODE = True
4646
pv.global_theme.window_size = [600, 600]
4747

48+
IMPORT_FILES_DIR = Path(Path(__file__).parent, "files", "import")
49+
DSCOSCRIPTS_FILES_DIR = Path(Path(__file__).parent, "files", "disco_scripts")
50+
FILES_DIR = Path(Path(__file__).parent, "files")
51+
4852

4953
# TODO: re-enable when Linux service is able to use measurement tools
5054
def skip_if_linux(modeler: Modeler, test_name: str, element_not_available: str):

tests/integration/test_design.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
from ansys.geometry.core.shapes.parameterization import Interval, ParamUV
6161
from ansys.geometry.core.sketch import Sketch
6262

63-
from .conftest import skip_if_linux
63+
from .conftest import FILES_DIR, skip_if_linux
6464

6565

6666
def test_design_extrusion_and_material_assignment(modeler: Modeler):
@@ -1935,7 +1935,7 @@ def test_get_active_design(modeler: Modeler):
19351935
def test_get_collision(modeler: Modeler):
19361936
"""Test the collision state between two bodies."""
19371937
skip_if_linux(modeler, test_get_collision.__name__, "get_collision") # Skip test on Linux
1938-
design = modeler.open_file("./tests/integration/files/MixingTank.scdocx")
1938+
design = modeler.open_file(FILES_DIR / "MixingTank.scdocx")
19391939
body1 = design.bodies[0]
19401940
body2 = design.bodies[1]
19411941
body3 = design.bodies[2]

tests/integration/test_design_import.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# SOFTWARE.
2222
"""Test design import."""
2323

24+
from pathlib import Path
25+
2426
import numpy as np
2527
from pint import Quantity
2628
import pytest
@@ -33,7 +35,7 @@
3335
from ansys.geometry.core.misc import UNITS
3436
from ansys.geometry.core.sketch import Sketch
3537

36-
from .conftest import skip_if_linux
38+
from .conftest import FILES_DIR, IMPORT_FILES_DIR, skip_if_linux
3739

3840

3941
def _checker_method(comp: Component, comp_ref: Component, precise_check: bool = True) -> None:
@@ -135,7 +137,7 @@ def test_design_import_with_surfaces_issue834(modeler: Modeler):
135137
skip_if_linux(modeler, test_design_import_with_surfaces_issue834.__name__, "open_file")
136138

137139
# Open the design
138-
design = modeler.open_file("./tests/integration/files/DuplicateFacesDesignBefore.scdocx")
140+
design = modeler.open_file(Path(FILES_DIR, "DuplicateFacesDesignBefore.scdocx"))
139141

140142
# Check that there are two bodies
141143
assert len(design.bodies) == 2
@@ -207,39 +209,39 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
207209
# file = tmp_path_factory.mktemp("test_design_import") / "two_cars.igs"
208210
# design.download(file, DesignFileFormat.IGES)
209211
# design2 = modeler.open_file(file)
210-
# design3 = modeler.open_file("./tests/integration/files/import/twoCars.igs")
212+
# design3 = modeler.open_file(Path(IMPORT_FILES_DIR, "twoCars.igs")
211213
# _checker_method(design2, design3, False)
212214

213215
# STEP
214216
file = tmp_path_factory.mktemp("test_design_import") / "two_cars.step"
215217
design.download(file, DesignFileFormat.STEP)
216218
design2 = modeler.open_file(file)
217-
design3 = modeler.open_file("./tests/integration/files/import/twoCars.stp")
219+
design3 = modeler.open_file(Path(IMPORT_FILES_DIR, "twoCars.stp"))
218220
_checker_method(design2, design3, False)
219221

220222
# Catia
221-
design2 = modeler.open_file("./tests/integration/files/import/catia_car/car.CATProduct")
223+
design2 = modeler.open_file(Path(IMPORT_FILES_DIR, "catia_car/car.CATProduct"))
222224
_checker_method(design, design2, False)
223225

224226
# Rhino
225-
design2 = modeler.open_file("./tests/integration/files/import/box.3dm")
227+
design2 = modeler.open_file(Path(IMPORT_FILES_DIR, "box.3dm"))
226228
assert len(design2.components) == 1
227229
assert len(design2.components[0].bodies) == 1
228230

229231
# Stride
230-
design2 = modeler.open_file("./tests/integration/files/import/sample_box.project")
232+
design2 = modeler.open_file(Path(IMPORT_FILES_DIR, "sample_box.project"))
231233
assert len(design2.bodies) == 1
232234

233235
# SolidWorks
234-
design2 = modeler.open_file("./tests/integration/files/import/partColor.SLDPRT")
236+
design2 = modeler.open_file(Path(IMPORT_FILES_DIR, "partColor.SLDPRT"))
235237
assert len(design2.components[0].bodies) == 1
236238

237239
# .par
238-
design2 = modeler.open_file("./tests/integration/files/import/Tank_Bottom.par")
240+
design2 = modeler.open_file(Path(IMPORT_FILES_DIR, "Tank_Bottom.par"))
239241
assert len(design2.bodies) == 1
240242

241243
# .prt
242-
design2 = modeler.open_file("./tests/integration/files/import/disk1.prt")
244+
design2 = modeler.open_file(Path(IMPORT_FILES_DIR, "disk1.prt"))
243245
assert len(design2.bodies) == 1
244246

245247

@@ -257,7 +259,7 @@ def test_design_insert(modeler: Modeler):
257259
comp.extrude_sketch("Body_Cylinder", sketch, 5)
258260

259261
# Insert a different file
260-
design.insert_file("./tests/integration/files/DuplicateFacesDesignBefore.scdocx")
262+
design.insert_file(Path(FILES_DIR, "DuplicateFacesDesignBefore.scdocx"))
261263

262264
# Check that there are two components
263265
assert len(design.components) == 2
@@ -280,7 +282,7 @@ def test_design_insert_with_import(modeler: Modeler):
280282
comp.extrude_sketch("Body_Cylinder", sketch, 5)
281283

282284
# Import and insert a different file
283-
design.insert_file("./tests/integration/files/import/catia_car/Wheel1.CATPart")
285+
design.insert_file(Path(IMPORT_FILES_DIR, "catia_car/Wheel1.CATPart"))
284286

285287
# Check that there are two components
286288
assert len(design.components) == 2

tests/integration/test_measurement_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from ansys.geometry.core.modeler import Modeler
2626
from ansys.geometry.core.tools.measurement_tools import Gap
2727

28-
from .conftest import skip_if_linux
28+
from .conftest import FILES_DIR, skip_if_linux
2929

3030

3131
def test_distance_property(modeler: Modeler):
@@ -39,6 +39,6 @@ def test_min_distance_between_objects(modeler: Modeler):
3939
skip_if_linux(
4040
modeler, test_min_distance_between_objects.__name__, "measurement_tools"
4141
) # Skip test on Linux
42-
design = modeler.open_file("./tests/integration/files/MixingTank.scdocx")
42+
design = modeler.open_file(FILES_DIR / "MixingTank.scdocx")
4343
gap = modeler.measurement_tools.min_distance_between_objects(design.bodies[2], design.bodies[1])
4444
assert abs(gap.distance._value - 0.0892) <= 0.01

0 commit comments

Comments
 (0)