Skip to content

Commit

Permalink
test: Add tests for new datamodel API (#3567)
Browse files Browse the repository at this point in the history
* test: Add test for new datamodel API

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: Adding test_mapped_api.py

* test: use datamodelgen

* test: use datamodelgen

* test: use datamodelgen

* fix: test

* fix: test

* test: fix container run

* test: fix container run
  • Loading branch information
mkundu1 authored Dec 16, 2024
1 parent 737bb65 commit 887210b
Show file tree
Hide file tree
Showing 8 changed files with 1,336 additions and 60 deletions.
11 changes: 11 additions & 0 deletions src/ansys/fluent/core/launcher/fluent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ def configure_container_dict(
container_dict["environment"] = {}
container_dict["environment"]["FLUENT_NO_AUTOMATIC_TRANSCRIPT"] = "1"

if (
os.getenv("REMOTING_NEW_DM_API") == "1"
or os.getenv("REMOTING_MAPPED_NEW_DM_API") == "1"
):
if "environment" not in container_dict:
container_dict["environment"] = {}
if os.getenv("REMOTING_NEW_DM_API") == "1":
container_dict["environment"]["REMOTING_NEW_DM_API"] = "1"
if os.getenv("REMOTING_MAPPED_NEW_DM_API") == "1":
container_dict["environment"]["REMOTING_MAPPED_NEW_DM_API"] = "1"

fluent_commands = ["-gu", f"-sifile={container_server_info_file}"] + args

container_dict_default = {}
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ def _del_item(self, key: str) -> None:
# On-deleted subscription objects are unsubscribed after the datamodel
# object is deleted.
self[key].add_on_deleted(
lambda _: self.service.subscriptions.unsubscribe_while_deleting(
lambda: self.service.subscriptions.unsubscribe_while_deleting(
self.rules, se_path, "after"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def _process_streaming(self, id, stream_begin_method, started_evt, *args, **kwar
elif response.HasField("commandAttributeChangedEventResponse"):
value = response.commandAttributeChangedEventResponse.value
cb[1](_convert_variant_to_value(value))
elif (
response.HasField("modifiedEventResponse")
or response.HasField("deletedEventResponse")
or response.HasField("affectedEventResponse")
):
elif response.HasField(
"modifiedEventResponse"
) or response.HasField("affectedEventResponse"):
cb[1](cb[0])
elif response.HasField("deletedEventResponse"):
cb[1]()
elif response.HasField("commandExecutedEventResponse"):
command = response.commandExecutedEventResponse.command
args = _convert_variant_to_value(
Expand Down
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from ansys.fluent.core.utils.file_transfer_service import RemoteFileTransferStrategy
from ansys.fluent.core.utils.fluent_version import FluentVersion

sys.path.append(Path(__file__).parent / "util")


def pytest_addoption(parser):
parser.addoption(
Expand Down Expand Up @@ -383,3 +385,16 @@ def periodic_rot_settings_session(new_solver_session):
@pytest.fixture
def disable_datamodel_cache(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(pyfluent, "DATAMODEL_USE_STATE_CACHE", False)


@pytest.fixture(params=["old", "new"])
def datamodel_api_version_all(request, monkeypatch: pytest.MonkeyPatch) -> None:
if request.param == "new":
monkeypatch.setenv("REMOTING_NEW_DM_API", "1")
monkeypatch.setenv("REMOTING_MAPPED_NEW_DM_API", "1")


@pytest.fixture
def datamodel_api_version_new(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("REMOTING_NEW_DM_API", "1")
monkeypatch.setenv("REMOTING_MAPPED_NEW_DM_API", "1")
Loading

0 comments on commit 887210b

Please sign in to comment.