diff --git a/doc/changelog.d/2048.added.md b/doc/changelog.d/2048.added.md new file mode 100644 index 0000000000..73b3b1c278 --- /dev/null +++ b/doc/changelog.d/2048.added.md @@ -0,0 +1 @@ +Allow logos linux 26 1 \ No newline at end of file diff --git a/src/ansys/geometry/core/tools/prepare_tools.py b/src/ansys/geometry/core/tools/prepare_tools.py index 241d47ad37..6c2a61b984 100644 --- a/src/ansys/geometry/core/tools/prepare_tools.py +++ b/src/ansys/geometry/core/tools/prepare_tools.py @@ -300,8 +300,10 @@ def find_logos( """ from ansys.geometry.core.designer.body import Body - if BackendType.is_linux_service(self._grpc_client.backend_type): - # not yet available in Linux + if BackendType.is_linux_service( + self._grpc_client.backend_type + ) and self._grpc_client.backend_version < (26, 1, 0): + # not yet available on Linux until 26.1.0 LOG.warning("Logo detection not available on Linux") return @@ -346,8 +348,10 @@ def find_and_remove_logos( """ from ansys.geometry.core.designer.body import Body - if BackendType.is_linux_service(self._grpc_client.backend_type): - # not yet available in Linux + if BackendType.is_linux_service( + self._grpc_client.backend_type + ) and self._grpc_client.backend_version < (26, 1, 0): + # not yet available on Linux until 26.1.0 LOG.warning("Logo detection not available on Linux") return diff --git a/tests/integration/test_prepare_tools.py b/tests/integration/test_prepare_tools.py index dd06fa1e65..e0dbf450c2 100644 --- a/tests/integration/test_prepare_tools.py +++ b/tests/integration/test_prepare_tools.py @@ -23,7 +23,6 @@ from pint import Quantity -from ansys.geometry.core.connection.backend import BackendType from ansys.geometry.core.math.point import Point2D from ansys.geometry.core.misc.measurements import UNITS from ansys.geometry.core.modeler import Modeler @@ -126,9 +125,6 @@ def test_enhanced_share_topology(modeler: Modeler): def test_detect_logos(modeler: Modeler): """Test logos are detected and deleted.""" - if BackendType.is_linux_service(modeler.client.backend_type): - # not yet available in Linux - return design = modeler.open_file(FILES_DIR / "partWithLogos.scdocx") component = [c for c in design.components if c.name == "Default"][0] body = [b for b in component.bodies if b.name == "Solid3"][0] @@ -151,9 +147,6 @@ def test_detect_logos(modeler: Modeler): def test_detect_and_fix_logo_as_problem_area(modeler: Modeler): """Test logos are detected and deleted as problem area""" - if BackendType.is_linux_service(modeler.client.backend_type): - # not yet available in Linux - return design = modeler.open_file(FILES_DIR / "partWithLogos.scdocx") # Get the component named "Default" component = [c for c in design.components if c.name == "Default"][0] diff --git a/tests/test_connection.py b/tests/test_connection.py index 55d8195e99..de489c554c 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -20,13 +20,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import os + from beartype.roar import BeartypeCallHintParamViolation import grpc import numpy as np from pint import Quantity import pytest -from ansys.geometry.core.connection.backend import ApiVersions +from ansys.geometry.core.connection.backend import ApiVersions, BackendType from ansys.geometry.core.connection.client import GrpcClient, wait_until_healthy from ansys.geometry.core.connection.conversions import ( frame_to_grpc_frame, @@ -40,6 +42,10 @@ sketch_segment_to_grpc_line, unit_vector_to_grpc_direction, ) +from ansys.geometry.core.connection.product_instance import ( + ProductInstance, + prepare_and_start_backend, +) from ansys.geometry.core.math import Frame, Plane, Point2D, Point3D, UnitVector3D from ansys.geometry.core.misc import UNITS, Angle from ansys.geometry.core.sketch import Arc, Polygon, SketchCircle, SketchEllipse, SketchSegment @@ -360,3 +366,54 @@ def test_api_versions_reader(): with pytest.raises(ValueError, match="0 is not a valid ApiVersions"): # Invalid version number ApiVersions.parse_input(0) + + +def test_product_instance_initialization(): + """Test the initialization of the ProductInstance class.""" + pid = -1234 # Example process ID + product_instance = ProductInstance(pid) + # Assert that the _pid attribute is correctly set + assert product_instance._pid == pid + assert product_instance.close() is False + + +def test_prepare_and_start_backend_conflicting_versions(): + """Test that providing both 'product_version' and 'version' raises a ValueError.""" + with pytest.raises( + ValueError, + match="Both 'product_version' and 'version' arguments are provided." + " Please use only 'version'.", + ): + prepare_and_start_backend( + backend_type=BackendType.WINDOWS_SERVICE, version=1900, product_version=1901 + ) + + +@pytest.mark.skipif( + os.name != "nt", + reason="Test skipped on Linux because it is specific to Windows backends.", +) +def test_prepare_and_start_backend_unavailable_version(): + """Test that an unavailable product version raises a SystemError.""" + with pytest.raises( + SystemError, + match="The requested Ansys product's version 1901 is not available," + " please specify a different version.", + ): + prepare_and_start_backend(backend_type=BackendType.WINDOWS_SERVICE, product_version=1901) + + +@pytest.mark.skipif( + os.name != "nt", + reason="Test skipped on Linux because it is specific to Windows backends.", +) +def test_prepare_and_start_backend_invalid_version(): + """Test that a non-integer 'version' raises a ValueError.""" + with pytest.raises( + ValueError, + match="The 'version' argument must be an integer representing the product version.", + ): + prepare_and_start_backend( + backend_type=BackendType.WINDOWS_SERVICE, + version="invalid_version", # Pass a non-integer value for version + )