From 38e26826a71fc10d4fd2a126247bf472d4e5e3bb Mon Sep 17 00:00:00 2001 From: Raphael Luciano Date: Wed, 16 Oct 2024 08:53:50 -0400 Subject: [PATCH] fix: Hiding switch-to-meshing-mode command from tui and settings (#3381) * hiding command from tui and solver.settings * using Fluent command name instead of Python name * adding to tests --- src/ansys/fluent/core/services/datamodel_tui.py | 6 +++--- src/ansys/fluent/core/solver/flobject.py | 1 + tests/test_settings_api.py | 10 +++++----- tests/test_tui_api.py | 10 +++++----- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ansys/fluent/core/services/datamodel_tui.py b/src/ansys/fluent/core/services/datamodel_tui.py index 979d8192207..823e8f97def 100644 --- a/src/ansys/fluent/core/services/datamodel_tui.py +++ b/src/ansys/fluent/core/services/datamodel_tui.py @@ -330,13 +330,13 @@ def __dir__(self) -> list[str]: for x in PyMenu( self._service, self._version, self._mode, self._path ).get_child_names() - if x != "exit" + if x not in ["exit", "switch_to_meshing_mode"] ] def __getattribute__(self, name) -> Any: - if name == "exit" and not self._path: + if name in ["exit", "switch_to_meshing_mode"] and not self._path: raise AttributeError( - f"'{self.__class__.__name__}' object has no attribute 'exit'" + f"'{self.__class__.__name__}' object has no attribute '{name}'" ) try: attr = super().__getattribute__(name) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index c2f01751b7b..8674a5f9265 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -2089,6 +2089,7 @@ def _process_cls_names(info_dict, names, write_doc=False): commands = info.get("commands") if commands: commands.pop("exit", None) + commands.pop("switch-to-meshing-mode", None) if commands and not user_creatable: commands.pop("create", None) if commands: diff --git a/tests/test_settings_api.py b/tests/test_settings_api.py index 5fb85790d7d..8af1816ec5a 100644 --- a/tests/test_settings_api.py +++ b/tests/test_settings_api.py @@ -512,10 +512,10 @@ def test_child_alias_with_parent_path(mixing_elbow_settings_session): @pytest.mark.fluent_version(">=25.1") -def test_exit_not_in_settings(new_solver_session): +def test_commands_not_in_settings(new_solver_session): solver = new_solver_session - assert "exit" not in dir(solver.settings) - - with pytest.raises(AttributeError): - solver.settings.exit() + for command in ["exit", "switch_to_meshing_mode"]: + assert command not in dir(solver.settings) + with pytest.raises(AttributeError): + getattr(solver.settings, command) diff --git a/tests/test_tui_api.py b/tests/test_tui_api.py index 193f85c00cd..aef1d65ed68 100644 --- a/tests/test_tui_api.py +++ b/tests/test_tui_api.py @@ -61,10 +61,10 @@ def test_exit_not_in_meshing_tui(new_meshing_session): meshing.tui.exit() -def test_exit_not_in_solver_tui(new_solver_session): +def test_commands_not_in_solver_tui(new_solver_session): solver = new_solver_session - assert "exit" not in dir(solver.tui) - - with pytest.raises(AttributeError): - solver.tui.exit() + for command in ["exit", "switch_to_meshing_mode"]: + assert command not in dir(solver.tui) + with pytest.raises(AttributeError): + getattr(solver.tui, command)