From ef2f50dc127643cf4600d6572b8caaace0082d34 Mon Sep 17 00:00:00 2001 From: "paul.profizi" Date: Fri, 11 Aug 2023 15:56:59 +0200 Subject: [PATCH] Update testing --- tests/conftest.py | 4 +++ tests/test_fluid_simulation.py | 50 ++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0bbe3d478..d7238f06c 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -204,6 +204,10 @@ def grpc_server(): server.shutdown() +SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1 = meets_version( + get_server_version(core._global_server()), "7.1" +) + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 = meets_version( get_server_version(core._global_server()), "7.0" ) diff --git a/tests/test_fluid_simulation.py b/tests/test_fluid_simulation.py index e4d378769..dc32dc482 100644 --- a/tests/test_fluid_simulation.py +++ b/tests/test_fluid_simulation.py @@ -1,5 +1,8 @@ from ansys.dpf.core import examples -from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 +from conftest import ( + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1, +) import pytest from pytest import fixture @@ -162,26 +165,31 @@ def test_results_fluent_averaging_from_elemental_faces(self, fluent_simulation): assert result._core_object[0].location == post.locations.nodal # Request on faces (requires filter-out of cell zones) - with pytest.raises( - ValueError, - match="Querying an ElementalAndFaces result on " - "faces currently requires the use of face zone ids", - ): - _ = fluent_simulation.static_pressure(location=post.locations.faces) - # print(result) - # assert result.index.mesh_index.location == post.locations.faces - # assert result._core_object[0].location == post.locations.faces - # result._fc[0].plot() - with pytest.raises( - ValueError, - match="Querying an ElementalAndFaces result on " - "faces currently requires the use of face zone ids", - ): - _ = fluent_simulation.static_pressure_on_faces() - # print(result) - # assert result.index.mesh_index.location == post.locations.faces - # # assert result._core_object[0].location == post.locations.faces - # result.plot() + if not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1: + with pytest.raises( + ValueError, + match="Querying an ElementalAndFaces result on " + "faces currently requires the use of face zone ids", + ): + _ = fluent_simulation.static_pressure(location=post.locations.faces) + with pytest.raises( + ValueError, + match="Querying an ElementalAndFaces result on " + "faces currently requires the use of face zone ids", + ): + _ = fluent_simulation.static_pressure_on_faces() + else: + result = fluent_simulation.static_pressure(location=post.locations.faces) + # print(result) + assert result.index.mesh_index.location == post.locations.faces + assert result._core_object[0].location == post.locations.faces + # result._fc[0].plot() + + result = fluent_simulation.static_pressure_on_faces() + # print(result) + assert result.index.mesh_index.location == post.locations.faces + assert result._core_object[0].location == post.locations.faces + # result.plot() # Request on cells (requires filter-out of face zones) result = fluent_simulation.static_pressure(location=post.locations.elemental)