From d75d80165a52389022785aaa0633a0e8f6759dd0 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Tue, 17 Dec 2024 16:39:31 -0500 Subject: [PATCH] fix: todo --- src/ansys/fluent/core/services/datamodel_se.py | 9 +++------ tests/test_datamodel_api.py | 4 ++-- tests/test_datamodel_service.py | 6 +++--- tests/test_mapped_api.py | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index 1c6a5404762..469c2ae230a 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -808,7 +808,7 @@ def add_on_affected_at_type_path( return subscription def add_on_command_executed( - self, rules: str, path: str, command: str, obj, cb: Callable + self, rules: str, path: str, obj, cb: Callable ) -> EventSubscription: """Add on command executed.""" request_dict = { @@ -817,7 +817,6 @@ def add_on_command_executed( "rules": rules, "commandExecutedEventRequest": { "path": path, - "command": command, }, } ] @@ -1326,13 +1325,11 @@ def add_on_affected_at_type_path( self.rules, convert_path_to_se_path(self.path), child_type, self, cb ) - def add_on_command_executed(self, command: str, cb: Callable) -> EventSubscription: + def add_on_command_executed(self, cb: Callable) -> EventSubscription: """Register a callback for when a command is executed. Parameters ---------- - command : str - command name cb : Callable Callback function @@ -1342,7 +1339,7 @@ def add_on_command_executed(self, command: str, cb: Callable) -> EventSubscripti EventSubscription instance which can be used to unregister the callback """ return self.service.add_on_command_executed( - self.rules, convert_path_to_se_path(self.path), command, self, cb + self.rules, convert_path_to_se_path(self.path), self, cb ) diff --git a/tests/test_datamodel_api.py b/tests/test_datamodel_api.py index a78b4fca9fa..9d08fc138bc 100644 --- a/tests/test_datamodel_api.py +++ b/tests/test_datamodel_api.py @@ -339,7 +339,7 @@ def cb(obj, cmd, args): executed += 1 # TODO: In C++ API, we don't need to pass the command name - subscription = service.add_on_command_executed(app_name, "/", "C", root, cb) + subscription = service.add_on_command_executed(app_name, "/", root, cb) assert executed == 0 assert command is None assert arguments is None @@ -437,7 +437,7 @@ def test_datamodel_api_on_bad_input( app_name, "/", "CC", "isActive", root, lambda _: None ) with pytest.raises(RuntimeError if new_api else SubscribeEventError): # TODO: issue - service.add_on_command_executed(app_name, "/BB", "C", root, lambda _: None) + service.add_on_command_executed(app_name, "/BB", root, lambda _: None) @pytest.mark.fluent_version(">=25.2") diff --git a/tests/test_datamodel_service.py b/tests/test_datamodel_service.py index 289c5bc8a0e..eb6c1c6d5d3 100644 --- a/tests/test_datamodel_service.py +++ b/tests/test_datamodel_service.py @@ -231,7 +231,7 @@ def test_add_on_command_executed(new_meshing_session): meshing = new_meshing_session data = [] subscription = meshing.meshing.add_on_command_executed( - "ImportGeometry", lambda obj, command, args: data.append(True) + lambda obj, command, args: data.append(True) ) assert data == [] meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry") @@ -651,8 +651,8 @@ def test_on_command_executed_lifetime(new_solver_session): root = create_root_using_datamodelgen(solver._se_service, app_name) root.A["A1"] = {} data = [] - _ = root.A["A1"].add_on_command_executed("C", lambda *args: data.append(1)) - root.A["A1"].add_on_command_executed("C", lambda *args: data.append(2)) + _ = root.A["A1"].add_on_command_executed(lambda *args: data.append(1)) + root.A["A1"].add_on_command_executed(lambda *args: data.append(2)) gc.collect() assert "/test/command_executed/A:A1/C" in solver._se_service.subscriptions assert "/test/command_executed/A:A1/C-1" in solver._se_service.subscriptions diff --git a/tests/test_mapped_api.py b/tests/test_mapped_api.py index d647dcfc506..a2f82f81598 100644 --- a/tests/test_mapped_api.py +++ b/tests/test_mapped_api.py @@ -529,7 +529,7 @@ def cb(obj, cmd, args): arguments = args executed = True - subscription = service.add_on_command_executed(app_name, "/", "C", root, cb) + subscription = service.add_on_command_executed(app_name, "/", root, cb) assert not executed assert command is None assert arguments is None