Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add tests for new datamodel API #3567

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
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]()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not capture the object which is going to be deleted, will update the PyFluent API.

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
Loading