Skip to content

Commit

Permalink
fix: Hiding switch-to-meshing-mode command from tui and settings (#3381)
Browse files Browse the repository at this point in the history
* hiding command from tui and solver.settings

* using Fluent command name instead of Python name

* adding to tests
  • Loading branch information
raph-luc authored Oct 16, 2024
1 parent 365c21c commit 38e2682
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/ansys/fluent/core/services/datamodel_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions tests/test_settings_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 5 additions & 5 deletions tests/test_tui_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 38e2682

Please sign in to comment.