Skip to content

Commit 11ac170

Browse files
fix: fix parasolid export tests with more precise backend descriptor (#1802)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent ec33acc commit 11ac170

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

doc/changelog.d/1802.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix parasolid export tests with more precise backend descriptor

src/ansys/geometry/core/connection/backend.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ def is_core_service(backend_type: "BackendType") -> bool:
5757
BackendType.CORE_LINUX,
5858
)
5959

60+
@staticmethod
61+
def is_linux_service(backend_type: "BackendType") -> bool:
62+
"""Determine whether the backend is a Linux service or not.
63+
64+
Parameters
65+
----------
66+
backend_type : BackendType
67+
The backend type to check whether or not it's running on Linux.
68+
69+
Returns
70+
-------
71+
bool
72+
True if the backend is running on Linux, False otherwise.
73+
"""
74+
return backend_type in (
75+
BackendType.LINUX_SERVICE,
76+
BackendType.CORE_LINUX,
77+
)
78+
6079

6180
class ApiVersions(Enum):
6281
"""Provides an enum for all the compatibles API versions."""

src/ansys/geometry/core/designer/design.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,7 @@ def export_to_parasolid_text(self, location: Path | str | None = None) -> Path:
504504
The path to the saved file.
505505
"""
506506
# Determine the extension based on the backend type
507-
ext = (
508-
"x_t"
509-
if self._grpc_client.backend_type in (BackendType.LINUX_SERVICE, BackendType.CORE_LINUX)
510-
else "xmt_txt"
511-
)
507+
ext = "xmt_txt" if BackendType.is_linux_service(self._grpc_client.backend_type) else "x_t"
512508

513509
# Define the file location
514510
file_location = self.__build_export_file_location(location, ext)
@@ -534,11 +530,7 @@ def export_to_parasolid_bin(self, location: Path | str | None = None) -> Path:
534530
The path to the saved file.
535531
"""
536532
# Determine the extension based on the backend type
537-
ext = (
538-
"x_b"
539-
if self._grpc_client.backend_type in (BackendType.LINUX_SERVICE, BackendType.CORE_LINUX)
540-
else "xmt_bin"
541-
)
533+
ext = "xmt_bin" if BackendType.is_linux_service(self._grpc_client.backend_type) else "x_b"
542534

543535
# Define the file location
544536
file_location = self.__build_export_file_location(location, ext)

tests/integration/test_design.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ def test_download_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactor
10161016
assert file.exists()
10171017

10181018
# Check that we can also save it (even if it is not accessible on the server)
1019-
if modeler.client.backend_type in (BackendType.LINUX_SERVICE, BackendType.CORE_LINUX):
1019+
if BackendType.is_linux_service(modeler.client.backend_type):
10201020
file_save = "/tmp/cylinder-temp.scdocx"
10211021
else:
10221022
file_save = tmp_path_factory.mktemp("scdoc_files_save") / "cylinder.scdocx"

tests/integration/test_design_export.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ def test_export_to_parasolid_text(modeler: Modeler, tmp_path_factory: pytest.Tem
226226
# Define the location and expected file location
227227
location = tmp_path_factory.mktemp("test_export_to_parasolid_text")
228228

229-
if BackendType.is_core_service(modeler.client.backend_type):
230-
file_location = location / f"{design.name}.x_t"
231-
else:
229+
if BackendType.is_linux_service(modeler.client.backend_type):
232230
file_location = location / f"{design.name}.xmt_txt"
231+
else:
232+
file_location = location / f"{design.name}.x_t"
233233

234234
# Export to parasolid text
235235
design.export_to_parasolid_text(location)
@@ -249,10 +249,10 @@ def test_export_to_parasolid_binary(modeler: Modeler, tmp_path_factory: pytest.T
249249
# Define the location and expected file location
250250
location = tmp_path_factory.mktemp("test_export_to_parasolid_binary")
251251

252-
if BackendType.is_core_service(modeler.client.backend_type):
253-
file_location = location / f"{design.name}.x_b"
254-
else:
252+
if BackendType.is_linux_service(modeler.client.backend_type):
255253
file_location = location / f"{design.name}.xmt_bin"
254+
else:
255+
file_location = location / f"{design.name}.x_b"
256256

257257
# Export to parasolid binary
258258
design.export_to_parasolid_bin(location)

0 commit comments

Comments
 (0)