From fb2249dcba623a22c056ec6aff684bf50b7135b4 Mon Sep 17 00:00:00 2001 From: Dominik Gresch Date: Wed, 28 Aug 2024 10:40:41 +0200 Subject: [PATCH 1/3] Add step for testing on the released server --- .github/workflows/ci_cd.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 274d8946f4..c0af586680 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 + 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 From dcfdcb49111107ac51156edfebdd795025cca9bc Mon Sep 17 00:00:00 2001 From: Dominik Gresch Date: Wed, 28 Aug 2024 11:16:04 +0200 Subject: [PATCH 2/3] Mark expected failures --- .github/workflows/ci_cd.yml | 2 +- tests/conftest.py | 12 ++++++++++++ tests/unittests/test_model.py | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index c0af586680..b4f4fd753c 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -173,7 +173,7 @@ jobs: 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 }} + if: matrix.python-version == env.MAIN_PYTHON_VERSION working-directory: tests/unittests run: | docker pull $IMAGE_NAME diff --git a/tests/conftest.py b/tests/conftest.py index 47183c3827..4e7c632c74 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_until(acp_instance): + """Mark a test as expected to fail until 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..e0c12e4fa5 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_until): """ Test that the 'export_modeling_ply_geometries' method produces a file. The contents of the file are not checked. """ + xfail_until("25.1") out_filename = "modeling_ply_export.step" with tempfile.TemporaryDirectory() as tmp_dir: From 9e185805ad637e8434b0e5a3e9e3c72ce7169c52 Mon Sep 17 00:00:00 2001 From: Dominik Gresch Date: Wed, 28 Aug 2024 21:03:42 +0200 Subject: [PATCH 3/3] Discard unknown fields in clone when unlink is set --- .github/workflows/ci_cd.yml | 2 +- src/ansys/acp/core/_tree_objects/base.py | 3 +++ tests/conftest.py | 4 ++-- tests/unittests/test_model.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index b4f4fd753c..61d8ac80c3 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -177,7 +177,7 @@ jobs: 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 + 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" 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 4e7c632c74..e09540c005 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -264,8 +264,8 @@ def inner(model, relative_file_path="square_and_solid.stp"): @pytest.fixture -def xfail_until(acp_instance): - """Mark a test as expected to fail until a certain server version.""" +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): diff --git a/tests/unittests/test_model.py b/tests/unittests/test_model.py index e0c12e4fa5..d32bf6b368 100644 --- a/tests/unittests/test_model.py +++ b/tests/unittests/test_model.py @@ -251,12 +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, xfail_until): +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_until("25.1") + xfail_before("25.1") out_filename = "modeling_ply_export.step" with tempfile.TemporaryDirectory() as tmp_dir: