Skip to content

Commit

Permalink
Fix UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed May 3, 2024
1 parent fda0be7 commit 890a14c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pyaedt.application.design_solutions import model_names
from pyaedt.generic.general_methods import is_linux
from pyaedt.generic.general_methods import settings
from pyaedt.workflows import customize_automation_tab

test_subfolder = "T01"
if config["desktopVersion"] > "2022.2":
Expand Down Expand Up @@ -397,17 +398,18 @@ def test_36_test_load(self, add_app):
assert True

def test_37_add_custom_toolkit(self, desktop):
assert desktop.get_available_toolkits()
assert customize_automation_tab.available_toolkits

def test_38_toolkit(self, desktop):
file = os.path.join(self.local_scratch.path, "test.py")
with open(file, "w") as f:
f.write("import pyaedt\n")
assert desktop.add_script_to_menu(
"test_toolkit",
file,
assert customize_automation_tab.add_script_to_menu(
desktop_object=self.aedtapp.desktop_class, name="test_toolkit", script_file=file
)
assert customize_automation_tab.remove_script_from_menu(
desktop_object=self.aedtapp.desktop_class, name="test_toolkit"
)
assert desktop.remove_script_from_menu("test_toolkit")

def test_39_load_project(self, desktop):
new_project = os.path.join(self.local_scratch.path, "new.aedt")
Expand Down
12 changes: 6 additions & 6 deletions pyaedt/workflows/customize_automation_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,19 @@ def run_command(command):
# Install toolkit inside AEDT
remove_script_from_menu(
desktop_object=desktop_object,
toolkit_name=toolkit_name,
name=toolkit_info["name"],
product=product_name,
)


def remove_script_from_menu(desktop_object, toolkit_name, product="Project"):
def remove_script_from_menu(desktop_object, name, product="Project"):
"""Remove a toolkit script from the menu.
Parameters
----------
desktop_object : :class:pyaedt.desktop.Desktop
Desktop object.
toolkit_name : str
name : str
Name of the toolkit to remove.
product : str, optional
Product to which the toolkit applies. The default is ``"Project"``, in which case
Expand All @@ -540,11 +540,11 @@ def remove_script_from_menu(desktop_object, toolkit_name, product="Project"):

toolkit_dir = os.path.join(desktop_object.personallib, "Toolkits")
aedt_version = desktop_object.aedt_version_id
tool_dir = os.path.join(toolkit_dir, product, toolkit_name)
tool_dir = os.path.join(toolkit_dir, product, name)
shutil.rmtree(tool_dir, ignore_errors=True)
if aedt_version >= "2023.2":
remove_xml_tab(os.path.join(toolkit_dir, product), toolkit_name)
desktop_object.logger.info("{} toolkit removed successfully.".format(toolkit_name))
remove_xml_tab(os.path.join(toolkit_dir, product), name)
desktop_object.logger.info("{} toolkit removed successfully.".format(name))
return True


Expand Down
2 changes: 1 addition & 1 deletion pyaedt/workflows/project/toolkit_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def button_is_clicked(
desktop.logger.info("PyAEDT environment is not installed.")
else:
desktop.logger.info("Uninstall {}.".format(name))
remove_script_from_menu(desktop_object=desktop, toolkit_name=name, product=toolkit_level)
remove_script_from_menu(desktop_object=desktop, name=name, product=toolkit_level)

desktop.odesktop.CloseAllWindows()
desktop.odesktop.RefreshToolkitUI()
Expand Down

0 comments on commit 890a14c

Please sign in to comment.