diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 274d8946f4..61d8ac80c3 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -172,6 +172,16 @@ jobs: LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} IMAGE_NAME: "ghcr.io/ansys/acp${{ github.event.inputs.docker_image_suffix || ':latest' }}" + - name: "Unit testing (2024R2 server)" + if: matrix.python-version == env.MAIN_PYTHON_VERSION + working-directory: tests/unittests + run: | + docker pull $IMAGE_NAME + poetry run pytest -v --license-server=1055@$LICENSE_SERVER --no-server-log-files --docker-image=$IMAGE_NAME --cov=ansys.acp.core --cov-report=term --cov-report=xml --cov-report=html --cov-append + env: + LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} + IMAGE_NAME: "ghcr.io/ansys/acp:2024r2" + - name: "Upload coverage report (HTML)" uses: actions/upload-artifact@v4 if: matrix.python-version == env.MAIN_PYTHON_VERSION diff --git a/src/ansys/acp/core/_tree_objects/base.py b/src/ansys/acp/core/_tree_objects/base.py index 42c7afac8e..7f89e02d73 100644 --- a/src/ansys/acp/core/_tree_objects/base.py +++ b/src/ansys/acp/core/_tree_objects/base.py @@ -285,6 +285,9 @@ def clone(self: Self, *, unlink: bool = False) -> Self: new_object_info.properties.CopyFrom(self._pb_object.properties) if unlink: unlink_objects(new_object_info.properties) + # Since there may be links in the unknown fields, we need to + # discard them to avoid errors when storing the object. + new_object_info.properties.DiscardUnknownFields() # type: ignore new_object_info.info.name = self._pb_object.info.name return type(self)._from_object_info(object_info=new_object_info) diff --git a/tests/conftest.py b/tests/conftest.py index 47183c3827..e09540c005 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,6 +31,7 @@ import docker from hypothesis import settings +from packaging.version import parse as parse_version import pytest from ansys.acp.core import ( @@ -260,3 +261,14 @@ def inner(model, relative_file_path="square_and_solid.stp"): ) return inner + + +@pytest.fixture +def xfail_before(acp_instance): + """Mark a test as expected to fail before a certain server version.""" + + def inner(version: str): + if parse_version(acp_instance.server_version) < parse_version(version): + pytest.xfail(f"Expected to fail until server version {version!r}") + + return inner diff --git a/tests/unittests/test_model.py b/tests/unittests/test_model.py index 70b3f7bbf2..d32bf6b368 100644 --- a/tests/unittests/test_model.py +++ b/tests/unittests/test_model.py @@ -251,11 +251,12 @@ def test_regression_454(minimal_complete_model): assert not hasattr(minimal_complete_model, "store") -def test_modeling_ply_export(acp_instance, minimal_complete_model): +def test_modeling_ply_export(acp_instance, minimal_complete_model, xfail_before): """ Test that the 'export_modeling_ply_geometries' method produces a file. The contents of the file are not checked. """ + xfail_before("25.1") out_filename = "modeling_ply_export.step" with tempfile.TemporaryDirectory() as tmp_dir: