From 34e80248509714df74c3f8171842eaf083f9155a Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Fri, 11 Jul 2025 16:18:15 +0200 Subject: [PATCH 01/12] REFACTOR: Migrated export to 3d extension --- .../extensions/hfss3dlayout/export_to_3d.py | 292 ++++++++++-------- 1 file changed, 161 insertions(+), 131 deletions(-) diff --git a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py index 858c58cfd8d..a4211c0b9b5 100644 --- a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py +++ b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py @@ -22,129 +22,138 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from pathlib import Path +from dataclasses import dataclass +import os +import tkinter +from tkinter import ttk import ansys.aedt.core -import ansys.aedt.core.extensions.hfss3dlayout +from ansys.aedt.core.extensions.misc import ExtensionCommon +from ansys.aedt.core.extensions.misc import ExtensionCommonData from ansys.aedt.core.extensions.misc import get_aedt_version from ansys.aedt.core.extensions.misc import get_arguments from ansys.aedt.core.extensions.misc import get_port from ansys.aedt.core.extensions.misc import get_process_id from ansys.aedt.core.extensions.misc import is_student +from ansys.aedt.core.internal.errors import AEDTRuntimeError -port = get_port() -version = get_aedt_version() -aedt_process_id = get_process_id() -is_student = is_student() +PORT = get_port() +VERSION = get_aedt_version() +AEDT_PROCESS_ID = get_process_id() +IS_STUDENT = is_student() # Extension batch arguments -extension_arguments = {"choice": "Export to HFSS"} -extension_description = "Export to 3D" - -suffixes = {"Export to HFSS": "HFSS", "Export to Q3D": "Q3D", "Export to Maxwell 3D": "M3D", "Export to Icepak": "IPK"} - - -def frontend(): # pragma: no cover - import tkinter - from tkinter import ttk - - import PIL.Image - import PIL.ImageTk - - from ansys.aedt.core.extensions.misc import ExtensionTheme - - master = tkinter.Tk() - master.title(extension_description) - - # Detect if user closes the UI - master.flag = False - - # Load the logo for the main window - icon_path = Path(ansys.aedt.core.extensions.__path__[0]) / "images" / "large" / "logo.png" - im = PIL.Image.open(icon_path) - photo = PIL.ImageTk.PhotoImage(im) - - # Set the icon for the main window - master.iconphoto(True, photo) - - # Configure style for ttk buttons - style = ttk.Style() - theme = ExtensionTheme() - - # Apply light theme initially - theme.apply_light_theme(style) - master.theme = "light" - - # Set background color of the window - master.configure(bg=theme.light["widget_bg"]) - - label = ttk.Label(master, text="Choose an option:", relief=tkinter.RAISED, style="PyAEDT.TLabel") - label.grid(row=0, column=0, columnspan=2, pady=10) - - combo = ttk.Combobox(master, width=40, style="PyAEDT.TCombobox") # Set the width of the combobox - combo["values"] = ("Export to HFSS", "Export to Q3D", "Export to Maxwell 3D", "Export to Icepak") - combo.current(0) - combo.grid(row=1, column=0, columnspan=2, pady=10) - - combo.focus_set() - - def toggle_theme(): - if master.theme == "light": - set_dark_theme() - master.theme = "dark" - else: - set_light_theme() - master.theme = "light" - - def set_light_theme(): - master.configure(bg=theme.light["widget_bg"]) - theme.apply_light_theme(style) - change_theme_button.config(text="\u263d") # Sun icon for light theme - - def set_dark_theme(): - master.configure(bg=theme.dark["widget_bg"]) - theme.apply_dark_theme(style) - change_theme_button.config(text="\u2600") # Moon icon for dark theme - - # Create a frame for the toggle button to position it correctly - button_frame = ttk.Frame(master, style="PyAEDT.TFrame", relief=tkinter.SUNKEN, borderwidth=2) - button_frame.grid(row=2, column=1, pady=10, padx=10, sticky="ew") - - # Add the toggle theme button inside the frame - change_theme_button = ttk.Button( - button_frame, width=20, text="\u263d", command=toggle_theme, style="PyAEDT.TButton" - ) - change_theme_button.grid(row=0, column=0, padx=0) - - def callback(): - master.flag = True - master.choice_ui = combo.get() - master.destroy() - - b = ttk.Button(master, text="Export", width=20, command=callback, style="PyAEDT.TButton") - b.grid(row=2, column=0, pady=10, padx=10) - - tkinter.mainloop() - - choice_ui = getattr(master, "choice_ui", extension_arguments["choice"]) - - output_dict = {} - if master.flag: - output_dict = { - "choice": choice_ui, - } - return output_dict - - -def main(extension_args): - choice = extension_args["choice"] +EXTENSION_DEFAULT_ARGUMENTS = {"choice": "Export to HFSS"} +EXTENSION_TITLE = "Export to 3D" + +SUFFIXES = { + "Export to HFSS": "HFSS", + "Export to Q3D": "Q3D", + "Export to Maxwell 3D": "M3D", + "Export to Icepak": "IPK" +} + + +@dataclass +class ExportTo3DExtensionData(ExtensionCommonData): + """Data class containing user input and computed data.""" + + choice: str = EXTENSION_DEFAULT_ARGUMENTS["choice"] + + +class ExportTo3DExtension(ExtensionCommon): + """Extension for exporting to 3D in AEDT.""" + + def __init__(self, withdraw: bool = False): + # Initialize the common extension class with title and theme + super().__init__( + EXTENSION_TITLE, + theme_color="light", + withdraw=withdraw, + add_custom_content=False, + toggle_row=1, + toggle_column=1, + ) + # Add private attributes and initialize them through load info + self.__load_aedt_info() + + # Tkinter widgets + self.combo_choice = None + + # Trigger manually since add_extension_content requires info + self.add_extension_content() + + def __load_aedt_info(self): + """Load info.""" + design_type = self.aedt_application.design_type + if design_type != "HFSS 3D Layout Design": + self.release_desktop() + msg = "HFSS 3D Layout project is needed." + raise AEDTRuntimeError(msg) + + def add_extension_content(self): + """Add custom content to the extension UI.""" + + label = ttk.Label( + self.root, + text="Choose an option:", + width=30, + style="PyAEDT.TLabel" + ) + label.grid(row=0, column=0, columnspan=2, padx=15, pady=10) + + # Dropdown menu for export choices + self.combo_choice = ttk.Combobox( + self.root, + width=40, + style="PyAEDT.TCombobox", + name="combo_choice", + state="readonly" + ) + export_options = ( + "Export to HFSS", + "Export to Q3D", + "Export to Maxwell 3D", + "Export to Icepak" + ) + self.combo_choice["values"] = export_options + self.combo_choice.current(0) + self.combo_choice.grid( + row=0, column=1, columnspan=2, padx=15, pady=10 + ) + self.combo_choice.focus_set() + + def callback(extension: ExportTo3DExtension): + choice = extension.combo_choice.get() + + export_data = ExportTo3DExtensionData(choice=choice) + extension.data = export_data + self.root.destroy() + + ok_button = ttk.Button( + self.root, + text="Export", + width=20, + command=lambda: callback(self), + style="PyAEDT.TButton", + name="export", + ) + ok_button.grid(row=1, column=0, padx=15, pady=10) + + +def main(data: ExportTo3DExtensionData): + """Main function to run the export to 3D extension.""" + if not data.choice: + raise AEDTRuntimeError("No choice provided to the extension.") + + choice = data.choice app = ansys.aedt.core.Desktop( new_desktop=False, - version=version, - port=port, - aedt_process_id=aedt_process_id, - student_version=is_student, + version=VERSION, + port=PORT, + aedt_process_id=AEDT_PROCESS_ID, + student_version=IS_STUDENT, ) active_project = app.active_project() @@ -155,53 +164,74 @@ def main(extension_args): if active_design.GetDesignType() in ["HFSS 3D Layout Design"]: design_name = active_design.GetName().split(";")[1] else: # pragma: no cover - app.logger.debug("Hfss 3D Layout project is needed.") + app.logger.debug("HFSS 3D Layout project is needed.") app.release_desktop(False, False) - raise Exception("Hfss 3D Layout project is needed.") + raise AEDTRuntimeError("HFSS 3D Layout project is needed.") - h3d = ansys.aedt.core.Hfss3dLayout(project=project_name, design=design_name) + h3d = ansys.aedt.core.Hfss3dLayout( + project=project_name, design=design_name + ) setup = h3d.create_setup() - suffix = suffixes[choice] + suffix = SUFFIXES[choice] if choice == "Export to Q3D": - setup.export_to_q3d(h3d.project_file[:-5] + f"_{suffix}.aedt", keep_net_name=True) + project_file = h3d.project_file[:-5] + f"_{suffix}.aedt" + setup.export_to_q3d(project_file, keep_net_name=True) else: - setup.export_to_hfss(h3d.project_file[:-5] + f"_{suffix}.aedt", keep_net_name=True) + project_file = h3d.project_file[:-5] + f"_{suffix}.aedt" + setup.export_to_hfss(project_file, keep_net_name=True) h3d.delete_setup(setup.name) h3d.save_project() if choice == "Export to Q3D": - _ = ansys.aedt.core.Q3d(project=h3d.project_file[:-5] + f"_{suffix}.aedt") + project_file = h3d.project_file[:-5] + f"_{suffix}.aedt" + _ = ansys.aedt.core.Q3d(project=project_file) else: - aedtapp = ansys.aedt.core.Hfss(project=h3d.project_file[:-5] + f"_{suffix}.aedt") + project_file = h3d.project_file[:-5] + f"_{suffix}.aedt" + aedtapp = ansys.aedt.core.Hfss(project=project_file) aedtapp2 = None if choice == "Export to Maxwell 3D": - aedtapp2 = ansys.aedt.core.Maxwell3d(project=aedtapp.project_name) + aedtapp2 = ansys.aedt.core.Maxwell3d( + project=aedtapp.project_name + ) elif choice == "Export to Icepak": - aedtapp2 = ansys.aedt.core.Icepak(project=aedtapp.project_name) + aedtapp2 = ansys.aedt.core.Icepak( + project=aedtapp.project_name + ) if aedtapp2: - aedtapp2.copy_solid_bodies_from(aedtapp, no_vacuum=False, no_pec=False, include_sheets=True) + aedtapp2.copy_solid_bodies_from( + aedtapp, + no_vacuum=False, + no_pec=False, + include_sheets=True + ) aedtapp2.delete_design(aedtapp.design_name) aedtapp2.save_project() - if not extension_args["is_test"]: # pragma: no cover + if "PYTEST_CURRENT_TEST" not in os.environ: # pragma: no cover app.logger.info("Project generated correctly.") app.release_desktop(False, False) return True if __name__ == "__main__": # pragma: no cover - args = get_arguments(extension_arguments, extension_description) + args = get_arguments(EXTENSION_DEFAULT_ARGUMENTS, EXTENSION_TITLE) # Open UI - if not args["is_batch"]: # pragma: no cover - output = frontend() - if output: - for output_name, output_value in output.items(): - if output_name in extension_arguments: - args[output_name] = output_value - main(args) + if not args["is_batch"]: + extension: ExtensionCommon = ExportTo3DExtension( + withdraw=False + ) + + tkinter.mainloop() + + if extension.data is not None: + main(extension.data) + else: - main(args) + data = ExportTo3DExtensionData() + for key, value in args.items(): + setattr(data, key, value) + main(data) From f67202f717b7f8f2cba08e40ff0442a8d78de633 Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Fri, 11 Jul 2025 16:18:17 +0200 Subject: [PATCH 02/12] TEST: Added export to 3d extension system and unit tests --- tests/system/extensions/test_export_to_3d.py | 145 +++++++ tests/unit/extensions/test_export_to_3d.py | 381 +++++++++++++++++++ 2 files changed, 526 insertions(+) create mode 100644 tests/system/extensions/test_export_to_3d.py create mode 100644 tests/unit/extensions/test_export_to_3d.py diff --git a/tests/system/extensions/test_export_to_3d.py b/tests/system/extensions/test_export_to_3d.py new file mode 100644 index 00000000000..4b975f1e070 --- /dev/null +++ b/tests/system/extensions/test_export_to_3d.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import pytest + +from ansys.aedt.core import Hfss +from ansys.aedt.core import Hfss3dLayout +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + ExportTo3DExtension, +) +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + ExportTo3DExtensionData, +) +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main +from ansys.aedt.core.internal.errors import AEDTRuntimeError + + +def test_export_to_3d_extension_button(add_app): + """Test the Export button in the Export to 3D extension.""" + data = ExportTo3DExtensionData(choice="Export to HFSS") + + # Create an HFSS 3D Layout application + aedt_app = add_app( + application=Hfss3dLayout, + project_name="export_to_3d", + design_name="test_export", + ) + + # Create a simple stackup and net for the export to work + aedt_app.modeler.layers.add_layer( + "signal", "signal", thickness="0.035mm", elevation="0mm" + ) + + # Test that the extension can be instantiated + extension = ExportTo3DExtension(withdraw=True) + extension.root.nametowidget("export").invoke() + + assert data.choice == extension.data.choice + assert main(extension.data) + + +def test_export_to_3d_q3d_choice(add_app): + """Test the Export to Q3D functionality.""" + # Create an HFSS 3D Layout application + aedt_app = add_app( + application=Hfss3dLayout, + project_name="export_to_3d_q3d", + design_name="test_q3d_export", + ) + + # Create a simple stackup for the export to work + aedt_app.modeler.layers.add_layer( + "signal", "signal", thickness="0.035mm", elevation="0mm" + ) + + data = ExportTo3DExtensionData(choice="Export to Q3D") + result = main(data) + + assert result is True + + +def test_export_to_3d_exceptions(add_app): + """Test exceptions thrown by the Export to 3D extension.""" + # Test with no choice + data = ExportTo3DExtensionData(choice=None) + with pytest.raises(AEDTRuntimeError): + main(data) + + # Test with empty choice + data = ExportTo3DExtensionData(choice="") + with pytest.raises(AEDTRuntimeError): + main(data) + + # Test with wrong application type (HFSS instead of 3D Layout) + _ = add_app( + application=Hfss, + project_name="export_wrong_app", + design_name="wrong_design", + ) + + data = ExportTo3DExtensionData(choice="Export to HFSS") + + with pytest.raises(AEDTRuntimeError): + main(data) + + +def test_export_to_3d_maxwell_choice(add_app): + """Test the Export to Maxwell 3D functionality.""" + # Create an HFSS 3D Layout application + aedt_app = add_app( + application=Hfss3dLayout, + project_name="export_to_3d_maxwell", + design_name="test_maxwell_export", + ) + + # Create a simple stackup for the export to work + aedt_app.modeler.layers.add_layer( + "signal", "signal", thickness="0.035mm", elevation="0mm" + ) + + data = ExportTo3DExtensionData(choice="Export to Maxwell 3D") + result = main(data) + + assert result is True + + +def test_export_to_3d_icepak_choice(add_app): + """Test the Export to Icepak functionality.""" + # Create an HFSS 3D Layout application + aedt_app = add_app( + application=Hfss3dLayout, + project_name="export_to_3d_icepak", + design_name="test_icepak_export", + ) + + # Create a simple stackup for the export to work + aedt_app.modeler.layers.add_layer( + "signal", "signal", thickness="0.035mm", elevation="0mm" + ) + + data = ExportTo3DExtensionData(choice="Export to Icepak") + result = main(data) + + assert result is True diff --git a/tests/unit/extensions/test_export_to_3d.py b/tests/unit/extensions/test_export_to_3d.py new file mode 100644 index 00000000000..9504c15206e --- /dev/null +++ b/tests/unit/extensions/test_export_to_3d.py @@ -0,0 +1,381 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +from unittest.mock import MagicMock +from unittest.mock import PropertyMock +from unittest.mock import patch + +import pytest + +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + EXTENSION_TITLE, +) +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + ExportTo3DExtension, +) +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + ExportTo3DExtensionData, +) +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main +from ansys.aedt.core.extensions.misc import ExtensionCommon +from ansys.aedt.core.internal.errors import AEDTRuntimeError + + +@pytest.fixture +def mock_aedt_app_3dlayout(): + """Fixture to create a mock AEDT application with 3D Layout.""" + mock_aedt_application = MagicMock() + mock_aedt_application.design_type = "HFSS 3D Layout Design" + + with patch.object( + ExtensionCommon, + "aedt_application", + new_callable=PropertyMock + ) as mock_aedt_application_property: + mock_aedt_application_property.return_value = ( + mock_aedt_application + ) + yield mock_aedt_application + + +@pytest.fixture +def mock_aedt_app_wrong_design(): + """Fixture to create a mock AEDT application with wrong design type.""" + mock_aedt_application = MagicMock() + mock_aedt_application.design_type = "HFSS" + + with patch.object( + ExtensionCommon, + "aedt_application", + new_callable=PropertyMock + ) as mock_aedt_application_property: + mock_aedt_application_property.return_value = ( + mock_aedt_application + ) + yield mock_aedt_application + + +@patch("ansys.aedt.core.extensions.misc.Desktop") +def test_export_to_3d_extension_default( + mock_desktop, mock_aedt_app_3dlayout +): + """Test instantiation of the Export to 3D extension.""" + mock_desktop.return_value = MagicMock() + + extension = ExportTo3DExtension(withdraw=True) + + assert EXTENSION_TITLE == extension.root.title() + assert "light" == extension.root.theme + + extension.root.destroy() + + +@patch("ansys.aedt.core.extensions.misc.Desktop") +def test_export_to_3d_extension_export_button( + mock_desktop, mock_aedt_app_3dlayout +): + """Test the export button functionality in the Export to 3D ext.""" + mock_desktop.return_value = MagicMock() + + extension = ExportTo3DExtension(withdraw=True) + + # Test default selection (Export to HFSS) + extension.root.nametowidget("export").invoke() + data: ExportTo3DExtensionData = extension.data + + assert "Export to HFSS" == data.choice + + # Test different selection + extension = ExportTo3DExtension(withdraw=True) + extension.combo_choice.current(1) # Select "Export to Q3D" + extension.root.nametowidget("export").invoke() + data: ExportTo3DExtensionData = extension.data + + assert "Export to Q3D" == data.choice + + +@patch("ansys.aedt.core.extensions.misc.Desktop") +def test_export_to_3d_extension_wrong_design_type( + mock_desktop, mock_aedt_app_wrong_design +): + """Test exception when wrong design type is used.""" + mock_desktop.return_value = MagicMock() + + with pytest.raises( + AEDTRuntimeError, match="HFSS 3D Layout project is needed." + ): + ExportTo3DExtension(withdraw=True) + + +def test_export_to_3d_extension_data(): + """Test the ExportTo3DExtensionData class.""" + # Test default values + data = ExportTo3DExtensionData() + assert "Export to HFSS" == data.choice + + # Test custom values + data = ExportTo3DExtensionData(choice="Export to Q3D") + assert "Export to Q3D" == data.choice + + +def test_main_function_no_choice(): + """Test main function with no choice provided.""" + data = ExportTo3DExtensionData(choice="") + + with pytest.raises( + AEDTRuntimeError, match="No choice provided to the extension." + ): + main(data) + + +def test_main_function_none_choice(): + """Test main function with None choice.""" + data = ExportTo3DExtensionData(choice=None) + + with pytest.raises( + AEDTRuntimeError, match="No choice provided to the extension." + ): + main(data) + + +@patch("ansys.aedt.core.Desktop") +def test_main_function_wrong_design_type_in_main(mock_desktop_class): + """Test main function when active design is not HFSS 3D Layout.""" + # Mock the Desktop and its methods + mock_desktop = MagicMock() + mock_desktop_class.return_value = mock_desktop + + mock_active_project = MagicMock() + mock_active_project.GetName.return_value = "test_project" + mock_desktop.active_project.return_value = mock_active_project + + mock_active_design = MagicMock() + # Wrong design type + mock_active_design.GetDesignType.return_value = "HFSS" + mock_desktop.active_design.return_value = mock_active_design + + data = ExportTo3DExtensionData(choice="Export to HFSS") + + with pytest.raises( + AEDTRuntimeError, match="HFSS 3D Layout project is needed." + ): + main(data) + + +@patch("ansys.aedt.core.Desktop") +@patch("ansys.aedt.core.Hfss3dLayout") +def test_main_function_export_to_q3d( + mock_hfss3dlayout_class, mock_desktop_class +): + """Test main function for Export to Q3D choice.""" + # Mock the Desktop and its methods + mock_desktop = MagicMock() + mock_desktop_class.return_value = mock_desktop + + mock_active_project = MagicMock() + mock_active_project.GetName.return_value = "test_project" + mock_desktop.active_project.return_value = mock_active_project + + mock_active_design = MagicMock() + mock_active_design.GetDesignType.return_value = ( + "HFSS 3D Layout Design" + ) + mock_active_design.GetName.return_value = "design;test_design" + mock_desktop.active_design.return_value = mock_active_design + + # Mock Hfss3dLayout + mock_h3d = MagicMock() + mock_h3d.project_file = "test_project.aedt" + mock_setup = MagicMock() + mock_setup.name = "test_setup" + mock_h3d.create_setup.return_value = mock_setup + mock_hfss3dlayout_class.return_value = mock_h3d + + with patch("ansys.aedt.core.Q3d") as mock_q3d: + data = ExportTo3DExtensionData(choice="Export to Q3D") + result = main(data) + + assert result is True + mock_setup.export_to_q3d.assert_called_once() + mock_h3d.delete_setup.assert_called_once_with("test_setup") + mock_h3d.save_project.assert_called_once() + mock_q3d.assert_called_once() + + +@patch("ansys.aedt.core.Desktop") +@patch("ansys.aedt.core.Hfss3dLayout") +@patch("ansys.aedt.core.Hfss") +def test_main_function_export_to_hfss( + mock_hfss_class, mock_hfss3dlayout_class, mock_desktop_class +): + """Test main function for Export to HFSS choice.""" + # Mock the Desktop and its methods + mock_desktop = MagicMock() + mock_desktop_class.return_value = mock_desktop + + mock_active_project = MagicMock() + mock_active_project.GetName.return_value = "test_project" + mock_desktop.active_project.return_value = mock_active_project + + mock_active_design = MagicMock() + mock_active_design.GetDesignType.return_value = ( + "HFSS 3D Layout Design" + ) + mock_active_design.GetName.return_value = "design;test_design" + mock_desktop.active_design.return_value = mock_active_design + + # Mock Hfss3dLayout + mock_h3d = MagicMock() + mock_h3d.project_file = "test_project.aedt" + mock_setup = MagicMock() + mock_setup.name = "test_setup" + mock_h3d.create_setup.return_value = mock_setup + mock_hfss3dlayout_class.return_value = mock_h3d + + # Mock HFSS + mock_hfss = MagicMock() + mock_hfss_class.return_value = mock_hfss + + data = ExportTo3DExtensionData(choice="Export to HFSS") + result = main(data) + + assert result is True + mock_setup.export_to_hfss.assert_called_once() + mock_h3d.delete_setup.assert_called_once_with("test_setup") + mock_h3d.save_project.assert_called_once() + mock_hfss_class.assert_called_once() + + +@patch("ansys.aedt.core.Desktop") +@patch("ansys.aedt.core.Hfss3dLayout") +@patch("ansys.aedt.core.Hfss") +@patch("ansys.aedt.core.Maxwell3d") +def test_main_function_export_to_maxwell( + mock_maxwell3d_class, + mock_hfss_class, + mock_hfss3dlayout_class, + mock_desktop_class, +): + """Test main function for Export to Maxwell 3D choice.""" + # Mock the Desktop and its methods + mock_desktop = MagicMock() + mock_desktop_class.return_value = mock_desktop + + mock_active_project = MagicMock() + mock_active_project.GetName.return_value = "test_project" + mock_desktop.active_project.return_value = mock_active_project + + mock_active_design = MagicMock() + mock_active_design.GetDesignType.return_value = ( + "HFSS 3D Layout Design" + ) + mock_active_design.GetName.return_value = "design;test_design" + mock_desktop.active_design.return_value = mock_active_design + + # Mock Hfss3dLayout + mock_h3d = MagicMock() + mock_h3d.project_file = "test_project.aedt" + mock_setup = MagicMock() + mock_setup.name = "test_setup" + mock_h3d.create_setup.return_value = mock_setup + mock_hfss3dlayout_class.return_value = mock_h3d + + # Mock HFSS and Maxwell3D + mock_hfss = MagicMock() + mock_hfss.project_name = "test_project" + mock_hfss.design_name = "test_design" + mock_hfss_class.return_value = mock_hfss + + mock_maxwell = MagicMock() + mock_maxwell3d_class.return_value = mock_maxwell + + data = ExportTo3DExtensionData(choice="Export to Maxwell 3D") + result = main(data) + + assert result is True + mock_setup.export_to_hfss.assert_called_once() + mock_h3d.delete_setup.assert_called_once_with("test_setup") + mock_h3d.save_project.assert_called_once() + mock_hfss_class.assert_called_once() + mock_maxwell3d_class.assert_called_once_with(project="test_project") + mock_maxwell.copy_solid_bodies_from.assert_called_once() + mock_maxwell.delete_design.assert_called_once_with("test_design") + mock_maxwell.save_project.assert_called_once() + + +@patch("ansys.aedt.core.Desktop") +@patch("ansys.aedt.core.Hfss3dLayout") +@patch("ansys.aedt.core.Hfss") +@patch("ansys.aedt.core.Icepak") +def test_main_function_export_to_icepak( + mock_icepak_class, + mock_hfss_class, + mock_hfss3dlayout_class, + mock_desktop_class, +): + """Test main function for Export to Icepak choice.""" + # Mock the Desktop and its methods + mock_desktop = MagicMock() + mock_desktop_class.return_value = mock_desktop + + mock_active_project = MagicMock() + mock_active_project.GetName.return_value = "test_project" + mock_desktop.active_project.return_value = mock_active_project + + mock_active_design = MagicMock() + mock_active_design.GetDesignType.return_value = ( + "HFSS 3D Layout Design" + ) + mock_active_design.GetName.return_value = "design;test_design" + mock_desktop.active_design.return_value = mock_active_design + + # Mock Hfss3dLayout + mock_h3d = MagicMock() + mock_h3d.project_file = "test_project.aedt" + mock_setup = MagicMock() + mock_setup.name = "test_setup" + mock_h3d.create_setup.return_value = mock_setup + mock_hfss3dlayout_class.return_value = mock_h3d + + # Mock HFSS and Icepak + mock_hfss = MagicMock() + mock_hfss.project_name = "test_project" + mock_hfss.design_name = "test_design" + mock_hfss_class.return_value = mock_hfss + + mock_icepak = MagicMock() + mock_icepak_class.return_value = mock_icepak + + data = ExportTo3DExtensionData(choice="Export to Icepak") + result = main(data) + + assert result is True + mock_setup.export_to_hfss.assert_called_once() + mock_h3d.delete_setup.assert_called_once_with("test_setup") + mock_h3d.save_project.assert_called_once() + mock_hfss_class.assert_called_once() + mock_icepak_class.assert_called_once_with(project="test_project") + mock_icepak.copy_solid_bodies_from.assert_called_once() + mock_icepak.delete_design.assert_called_once_with("test_design") + mock_icepak.save_project.assert_called_once() From 016e8c271cd6dbdc6e9e3b1002820aa32f7ece01 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:20:51 +0000 Subject: [PATCH 03/12] CHORE: Auto fixes from pre-commit hooks --- .../extensions/hfss3dlayout/export_to_3d.py | 54 +++--------- tests/system/extensions/test_export_to_3d.py | 24 ++---- tests/unit/extensions/test_export_to_3d.py | 84 +++++-------------- 3 files changed, 36 insertions(+), 126 deletions(-) diff --git a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py index a4211c0b9b5..1d3c30d64c6 100644 --- a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py +++ b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py @@ -46,12 +46,7 @@ EXTENSION_DEFAULT_ARGUMENTS = {"choice": "Export to HFSS"} EXTENSION_TITLE = "Export to 3D" -SUFFIXES = { - "Export to HFSS": "HFSS", - "Export to Q3D": "Q3D", - "Export to Maxwell 3D": "M3D", - "Export to Icepak": "IPK" -} +SUFFIXES = {"Export to HFSS": "HFSS", "Export to Q3D": "Q3D", "Export to Maxwell 3D": "M3D", "Export to Icepak": "IPK"} @dataclass @@ -94,33 +89,17 @@ def __load_aedt_info(self): def add_extension_content(self): """Add custom content to the extension UI.""" - label = ttk.Label( - self.root, - text="Choose an option:", - width=30, - style="PyAEDT.TLabel" - ) + label = ttk.Label(self.root, text="Choose an option:", width=30, style="PyAEDT.TLabel") label.grid(row=0, column=0, columnspan=2, padx=15, pady=10) # Dropdown menu for export choices self.combo_choice = ttk.Combobox( - self.root, - width=40, - style="PyAEDT.TCombobox", - name="combo_choice", - state="readonly" - ) - export_options = ( - "Export to HFSS", - "Export to Q3D", - "Export to Maxwell 3D", - "Export to Icepak" + self.root, width=40, style="PyAEDT.TCombobox", name="combo_choice", state="readonly" ) + export_options = ("Export to HFSS", "Export to Q3D", "Export to Maxwell 3D", "Export to Icepak") self.combo_choice["values"] = export_options self.combo_choice.current(0) - self.combo_choice.grid( - row=0, column=1, columnspan=2, padx=15, pady=10 - ) + self.combo_choice.grid(row=0, column=1, columnspan=2, padx=15, pady=10) self.combo_choice.focus_set() def callback(extension: ExportTo3DExtension): @@ -168,9 +147,7 @@ def main(data: ExportTo3DExtensionData): app.release_desktop(False, False) raise AEDTRuntimeError("HFSS 3D Layout project is needed.") - h3d = ansys.aedt.core.Hfss3dLayout( - project=project_name, design=design_name - ) + h3d = ansys.aedt.core.Hfss3dLayout(project=project_name, design=design_name) setup = h3d.create_setup() suffix = SUFFIXES[choice] @@ -193,20 +170,11 @@ def main(data: ExportTo3DExtensionData): aedtapp = ansys.aedt.core.Hfss(project=project_file) aedtapp2 = None if choice == "Export to Maxwell 3D": - aedtapp2 = ansys.aedt.core.Maxwell3d( - project=aedtapp.project_name - ) + aedtapp2 = ansys.aedt.core.Maxwell3d(project=aedtapp.project_name) elif choice == "Export to Icepak": - aedtapp2 = ansys.aedt.core.Icepak( - project=aedtapp.project_name - ) + aedtapp2 = ansys.aedt.core.Icepak(project=aedtapp.project_name) if aedtapp2: - aedtapp2.copy_solid_bodies_from( - aedtapp, - no_vacuum=False, - no_pec=False, - include_sheets=True - ) + aedtapp2.copy_solid_bodies_from(aedtapp, no_vacuum=False, no_pec=False, include_sheets=True) aedtapp2.delete_design(aedtapp.design_name) aedtapp2.save_project() @@ -221,9 +189,7 @@ def main(data: ExportTo3DExtensionData): # Open UI if not args["is_batch"]: - extension: ExtensionCommon = ExportTo3DExtension( - withdraw=False - ) + extension: ExtensionCommon = ExportTo3DExtension(withdraw=False) tkinter.mainloop() diff --git a/tests/system/extensions/test_export_to_3d.py b/tests/system/extensions/test_export_to_3d.py index 4b975f1e070..6cfd8878f20 100644 --- a/tests/system/extensions/test_export_to_3d.py +++ b/tests/system/extensions/test_export_to_3d.py @@ -26,12 +26,8 @@ from ansys.aedt.core import Hfss from ansys.aedt.core import Hfss3dLayout -from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - ExportTo3DExtension, -) -from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - ExportTo3DExtensionData, -) +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtension +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main from ansys.aedt.core.internal.errors import AEDTRuntimeError @@ -48,9 +44,7 @@ def test_export_to_3d_extension_button(add_app): ) # Create a simple stackup and net for the export to work - aedt_app.modeler.layers.add_layer( - "signal", "signal", thickness="0.035mm", elevation="0mm" - ) + aedt_app.modeler.layers.add_layer("signal", "signal", thickness="0.035mm", elevation="0mm") # Test that the extension can be instantiated extension = ExportTo3DExtension(withdraw=True) @@ -70,9 +64,7 @@ def test_export_to_3d_q3d_choice(add_app): ) # Create a simple stackup for the export to work - aedt_app.modeler.layers.add_layer( - "signal", "signal", thickness="0.035mm", elevation="0mm" - ) + aedt_app.modeler.layers.add_layer("signal", "signal", thickness="0.035mm", elevation="0mm") data = ExportTo3DExtensionData(choice="Export to Q3D") result = main(data) @@ -115,9 +107,7 @@ def test_export_to_3d_maxwell_choice(add_app): ) # Create a simple stackup for the export to work - aedt_app.modeler.layers.add_layer( - "signal", "signal", thickness="0.035mm", elevation="0mm" - ) + aedt_app.modeler.layers.add_layer("signal", "signal", thickness="0.035mm", elevation="0mm") data = ExportTo3DExtensionData(choice="Export to Maxwell 3D") result = main(data) @@ -135,9 +125,7 @@ def test_export_to_3d_icepak_choice(add_app): ) # Create a simple stackup for the export to work - aedt_app.modeler.layers.add_layer( - "signal", "signal", thickness="0.035mm", elevation="0mm" - ) + aedt_app.modeler.layers.add_layer("signal", "signal", thickness="0.035mm", elevation="0mm") data = ExportTo3DExtensionData(choice="Export to Icepak") result = main(data) diff --git a/tests/unit/extensions/test_export_to_3d.py b/tests/unit/extensions/test_export_to_3d.py index 9504c15206e..7015f167584 100644 --- a/tests/unit/extensions/test_export_to_3d.py +++ b/tests/unit/extensions/test_export_to_3d.py @@ -28,15 +28,9 @@ import pytest -from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - EXTENSION_TITLE, -) -from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - ExportTo3DExtension, -) -from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - ExportTo3DExtensionData, -) +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import EXTENSION_TITLE +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtension +from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main from ansys.aedt.core.extensions.misc import ExtensionCommon from ansys.aedt.core.internal.errors import AEDTRuntimeError @@ -48,14 +42,8 @@ def mock_aedt_app_3dlayout(): mock_aedt_application = MagicMock() mock_aedt_application.design_type = "HFSS 3D Layout Design" - with patch.object( - ExtensionCommon, - "aedt_application", - new_callable=PropertyMock - ) as mock_aedt_application_property: - mock_aedt_application_property.return_value = ( - mock_aedt_application - ) + with patch.object(ExtensionCommon, "aedt_application", new_callable=PropertyMock) as mock_aedt_application_property: + mock_aedt_application_property.return_value = mock_aedt_application yield mock_aedt_application @@ -65,21 +53,13 @@ def mock_aedt_app_wrong_design(): mock_aedt_application = MagicMock() mock_aedt_application.design_type = "HFSS" - with patch.object( - ExtensionCommon, - "aedt_application", - new_callable=PropertyMock - ) as mock_aedt_application_property: - mock_aedt_application_property.return_value = ( - mock_aedt_application - ) + with patch.object(ExtensionCommon, "aedt_application", new_callable=PropertyMock) as mock_aedt_application_property: + mock_aedt_application_property.return_value = mock_aedt_application yield mock_aedt_application @patch("ansys.aedt.core.extensions.misc.Desktop") -def test_export_to_3d_extension_default( - mock_desktop, mock_aedt_app_3dlayout -): +def test_export_to_3d_extension_default(mock_desktop, mock_aedt_app_3dlayout): """Test instantiation of the Export to 3D extension.""" mock_desktop.return_value = MagicMock() @@ -92,9 +72,7 @@ def test_export_to_3d_extension_default( @patch("ansys.aedt.core.extensions.misc.Desktop") -def test_export_to_3d_extension_export_button( - mock_desktop, mock_aedt_app_3dlayout -): +def test_export_to_3d_extension_export_button(mock_desktop, mock_aedt_app_3dlayout): """Test the export button functionality in the Export to 3D ext.""" mock_desktop.return_value = MagicMock() @@ -116,15 +94,11 @@ def test_export_to_3d_extension_export_button( @patch("ansys.aedt.core.extensions.misc.Desktop") -def test_export_to_3d_extension_wrong_design_type( - mock_desktop, mock_aedt_app_wrong_design -): +def test_export_to_3d_extension_wrong_design_type(mock_desktop, mock_aedt_app_wrong_design): """Test exception when wrong design type is used.""" mock_desktop.return_value = MagicMock() - with pytest.raises( - AEDTRuntimeError, match="HFSS 3D Layout project is needed." - ): + with pytest.raises(AEDTRuntimeError, match="HFSS 3D Layout project is needed."): ExportTo3DExtension(withdraw=True) @@ -143,9 +117,7 @@ def test_main_function_no_choice(): """Test main function with no choice provided.""" data = ExportTo3DExtensionData(choice="") - with pytest.raises( - AEDTRuntimeError, match="No choice provided to the extension." - ): + with pytest.raises(AEDTRuntimeError, match="No choice provided to the extension."): main(data) @@ -153,9 +125,7 @@ def test_main_function_none_choice(): """Test main function with None choice.""" data = ExportTo3DExtensionData(choice=None) - with pytest.raises( - AEDTRuntimeError, match="No choice provided to the extension." - ): + with pytest.raises(AEDTRuntimeError, match="No choice provided to the extension."): main(data) @@ -177,17 +147,13 @@ def test_main_function_wrong_design_type_in_main(mock_desktop_class): data = ExportTo3DExtensionData(choice="Export to HFSS") - with pytest.raises( - AEDTRuntimeError, match="HFSS 3D Layout project is needed." - ): + with pytest.raises(AEDTRuntimeError, match="HFSS 3D Layout project is needed."): main(data) @patch("ansys.aedt.core.Desktop") @patch("ansys.aedt.core.Hfss3dLayout") -def test_main_function_export_to_q3d( - mock_hfss3dlayout_class, mock_desktop_class -): +def test_main_function_export_to_q3d(mock_hfss3dlayout_class, mock_desktop_class): """Test main function for Export to Q3D choice.""" # Mock the Desktop and its methods mock_desktop = MagicMock() @@ -198,9 +164,7 @@ def test_main_function_export_to_q3d( mock_desktop.active_project.return_value = mock_active_project mock_active_design = MagicMock() - mock_active_design.GetDesignType.return_value = ( - "HFSS 3D Layout Design" - ) + mock_active_design.GetDesignType.return_value = "HFSS 3D Layout Design" mock_active_design.GetName.return_value = "design;test_design" mock_desktop.active_design.return_value = mock_active_design @@ -226,9 +190,7 @@ def test_main_function_export_to_q3d( @patch("ansys.aedt.core.Desktop") @patch("ansys.aedt.core.Hfss3dLayout") @patch("ansys.aedt.core.Hfss") -def test_main_function_export_to_hfss( - mock_hfss_class, mock_hfss3dlayout_class, mock_desktop_class -): +def test_main_function_export_to_hfss(mock_hfss_class, mock_hfss3dlayout_class, mock_desktop_class): """Test main function for Export to HFSS choice.""" # Mock the Desktop and its methods mock_desktop = MagicMock() @@ -239,9 +201,7 @@ def test_main_function_export_to_hfss( mock_desktop.active_project.return_value = mock_active_project mock_active_design = MagicMock() - mock_active_design.GetDesignType.return_value = ( - "HFSS 3D Layout Design" - ) + mock_active_design.GetDesignType.return_value = "HFSS 3D Layout Design" mock_active_design.GetName.return_value = "design;test_design" mock_desktop.active_design.return_value = mock_active_design @@ -287,9 +247,7 @@ def test_main_function_export_to_maxwell( mock_desktop.active_project.return_value = mock_active_project mock_active_design = MagicMock() - mock_active_design.GetDesignType.return_value = ( - "HFSS 3D Layout Design" - ) + mock_active_design.GetDesignType.return_value = "HFSS 3D Layout Design" mock_active_design.GetName.return_value = "design;test_design" mock_desktop.active_design.return_value = mock_active_design @@ -344,9 +302,7 @@ def test_main_function_export_to_icepak( mock_desktop.active_project.return_value = mock_active_project mock_active_design = MagicMock() - mock_active_design.GetDesignType.return_value = ( - "HFSS 3D Layout Design" - ) + mock_active_design.GetDesignType.return_value = "HFSS 3D Layout Design" mock_active_design.GetName.return_value = "design;test_design" mock_desktop.active_design.return_value = mock_active_design From 4ebfa7c79451365243fce232a4a0de6e19cc5d6d Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:23:34 +0000 Subject: [PATCH 04/12] chore: adding changelog file 6391.miscellaneous.md [dependabot-skip] --- doc/changelog.d/6391.miscellaneous.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/6391.miscellaneous.md diff --git a/doc/changelog.d/6391.miscellaneous.md b/doc/changelog.d/6391.miscellaneous.md new file mode 100644 index 00000000000..89f877444ec --- /dev/null +++ b/doc/changelog.d/6391.miscellaneous.md @@ -0,0 +1 @@ +6390 migrate export to 3d extension \ No newline at end of file From 553030bfa68b3ea9af1daf2bf088d7c96f882a5d Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Mon, 21 Jul 2025 17:57:16 +0200 Subject: [PATCH 05/12] FIX: Applied new extension common class for HFSS3DLayout --- src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py index 1d3c30d64c6..074b4c9835e 100644 --- a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py +++ b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py @@ -28,7 +28,7 @@ from tkinter import ttk import ansys.aedt.core -from ansys.aedt.core.extensions.misc import ExtensionCommon +from ansys.aedt.core.extensions.misc import ExtensionHFSS3DLayoutCommon from ansys.aedt.core.extensions.misc import ExtensionCommonData from ansys.aedt.core.extensions.misc import get_aedt_version from ansys.aedt.core.extensions.misc import get_arguments @@ -56,7 +56,7 @@ class ExportTo3DExtensionData(ExtensionCommonData): choice: str = EXTENSION_DEFAULT_ARGUMENTS["choice"] -class ExportTo3DExtension(ExtensionCommon): +class ExportTo3DExtension(ExtensionHFSS3DLayoutCommon): """Extension for exporting to 3D in AEDT.""" def __init__(self, withdraw: bool = False): @@ -189,7 +189,7 @@ def main(data: ExportTo3DExtensionData): # Open UI if not args["is_batch"]: - extension: ExtensionCommon = ExportTo3DExtension(withdraw=False) + extension: ExtensionHFSS3DLayoutCommon = ExportTo3DExtension(withdraw=False) tkinter.mainloop() From ce52a7f3da04c2f1a67f6f6c2ed748cc753cc030 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 15:58:24 +0000 Subject: [PATCH 06/12] CHORE: Auto fixes from pre-commit hooks --- src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py index 074b4c9835e..f08fa452177 100644 --- a/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py +++ b/src/ansys/aedt/core/extensions/hfss3dlayout/export_to_3d.py @@ -28,8 +28,8 @@ from tkinter import ttk import ansys.aedt.core -from ansys.aedt.core.extensions.misc import ExtensionHFSS3DLayoutCommon from ansys.aedt.core.extensions.misc import ExtensionCommonData +from ansys.aedt.core.extensions.misc import ExtensionHFSS3DLayoutCommon from ansys.aedt.core.extensions.misc import get_aedt_version from ansys.aedt.core.extensions.misc import get_arguments from ansys.aedt.core.extensions.misc import get_port From f5d11c0330090fe9fadb245136f3fc52401c4948 Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Mon, 21 Jul 2025 18:09:03 +0200 Subject: [PATCH 07/12] TEST: Fixed test --- tests/unit/extensions/test_export_to_3d.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/extensions/test_export_to_3d.py b/tests/unit/extensions/test_export_to_3d.py index 7015f167584..25e52693131 100644 --- a/tests/unit/extensions/test_export_to_3d.py +++ b/tests/unit/extensions/test_export_to_3d.py @@ -98,7 +98,10 @@ def test_export_to_3d_extension_wrong_design_type(mock_desktop, mock_aedt_app_wr """Test exception when wrong design type is used.""" mock_desktop.return_value = MagicMock() - with pytest.raises(AEDTRuntimeError, match="HFSS 3D Layout project is needed."): + with pytest.raises( + AEDTRuntimeError, + match="This extension can only be used with HFSS 3D Layout designs." + ): ExportTo3DExtension(withdraw=True) @@ -117,7 +120,9 @@ def test_main_function_no_choice(): """Test main function with no choice provided.""" data = ExportTo3DExtensionData(choice="") - with pytest.raises(AEDTRuntimeError, match="No choice provided to the extension."): + with pytest.raises( + AEDTRuntimeError, match="No choice provided to the extension." + ): main(data) From aa225b9857c38741445ea8b01b67c738e2ec34a2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 16:09:57 +0000 Subject: [PATCH 08/12] CHORE: Auto fixes from pre-commit hooks --- tests/unit/extensions/test_export_to_3d.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/unit/extensions/test_export_to_3d.py b/tests/unit/extensions/test_export_to_3d.py index 25e52693131..a14ca455f93 100644 --- a/tests/unit/extensions/test_export_to_3d.py +++ b/tests/unit/extensions/test_export_to_3d.py @@ -98,10 +98,7 @@ def test_export_to_3d_extension_wrong_design_type(mock_desktop, mock_aedt_app_wr """Test exception when wrong design type is used.""" mock_desktop.return_value = MagicMock() - with pytest.raises( - AEDTRuntimeError, - match="This extension can only be used with HFSS 3D Layout designs." - ): + with pytest.raises(AEDTRuntimeError, match="This extension can only be used with HFSS 3D Layout designs."): ExportTo3DExtension(withdraw=True) @@ -120,9 +117,7 @@ def test_main_function_no_choice(): """Test main function with no choice provided.""" data = ExportTo3DExtensionData(choice="") - with pytest.raises( - AEDTRuntimeError, match="No choice provided to the extension." - ): + with pytest.raises(AEDTRuntimeError, match="No choice provided to the extension."): main(data) From e4caa6384221459d2029590bc0ae34268bdb15e8 Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Tue, 22 Jul 2025 11:49:56 +0200 Subject: [PATCH 09/12] FIX: Updated extension test --- tests/system/extensions/test_45_extensions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/system/extensions/test_45_extensions.py b/tests/system/extensions/test_45_extensions.py index 0713624464c..c29ed30b344 100644 --- a/tests/system/extensions/test_45_extensions.py +++ b/tests/system/extensions/test_45_extensions.py @@ -67,15 +67,16 @@ def test_02_hfss_push(self, add_app): aedtapp.close_project(aedtapp.project_name) def test_03_hfss3dlayout_export_3d_q3d(self, local_scratch, add_app): + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder ) aedtapp.save_project(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_q3d.aedt")) - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main - assert main({"is_test": True, "choice": "Export to Q3D"}) + assert main(ExportTo3DExtensionData(choice="Export to Q3D")) assert os.path.isfile(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_q3d_Q3D.aedt")) aedtapp.close_project(os.path.basename(aedtapp.project_file[:-5]) + "_Q3D") From de2252c6f0f65d369f8ec7ca58afef2025721be8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 09:50:41 +0000 Subject: [PATCH 10/12] CHORE: Auto fixes from pre-commit hooks --- tests/system/extensions/test_45_extensions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/extensions/test_45_extensions.py b/tests/system/extensions/test_45_extensions.py index c29ed30b344..10f8de9ea99 100644 --- a/tests/system/extensions/test_45_extensions.py +++ b/tests/system/extensions/test_45_extensions.py @@ -69,13 +69,13 @@ def test_02_hfss_push(self, add_app): def test_03_hfss3dlayout_export_3d_q3d(self, local_scratch, add_app): from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main + aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder ) aedtapp.save_project(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_q3d.aedt")) - assert main(ExportTo3DExtensionData(choice="Export to Q3D")) assert os.path.isfile(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_q3d_Q3D.aedt")) From 6d5174612f17517523c4d5fc9c921830eacd3316 Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Tue, 22 Jul 2025 16:50:32 +0200 Subject: [PATCH 11/12] FIX: Fixed tests --- tests/system/extensions/test_45_extensions.py | 106 +++++++++++++----- 1 file changed, 78 insertions(+), 28 deletions(-) diff --git a/tests/system/extensions/test_45_extensions.py b/tests/system/extensions/test_45_extensions.py index c29ed30b344..566c77c496f 100644 --- a/tests/system/extensions/test_45_extensions.py +++ b/tests/system/extensions/test_45_extensions.py @@ -29,7 +29,9 @@ import ansys.aedt.core from ansys.aedt.core.generic.settings import is_linux -from tests.system.extensions.conftest import local_path as extensions_local_path +from tests.system.extensions.conftest import ( + local_path as extensions_local_path, +) from tests.system.general.conftest import local_path push_project = "push_excitation" @@ -52,7 +54,9 @@ def init(self, desktop): def test_02_hfss_push(self, add_app): aedtapp = add_app(project_name=push_project, subfolder=test_subfolder) - from ansys.aedt.core.extensions.hfss.push_excitation_from_file import main + from ansys.aedt.core.extensions.hfss.push_excitation_from_file import ( + main, + ) # No choice file_path = os.path.join(local_path, "example_models", "T20", "Sinusoidal.csv") @@ -67,15 +71,19 @@ def test_02_hfss_push(self, add_app): aedtapp.close_project(aedtapp.project_name) def test_03_hfss3dlayout_export_3d_q3d(self, local_scratch, add_app): - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + ExportTo3DExtensionData, + ) + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + main, + ) + aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder ) aedtapp.save_project(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_q3d.aedt")) - assert main(ExportTo3DExtensionData(choice="Export to Q3D")) assert os.path.isfile(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_q3d_Q3D.aedt")) @@ -83,30 +91,38 @@ def test_03_hfss3dlayout_export_3d_q3d(self, local_scratch, add_app): aedtapp.close_project(aedtapp.project_name) def test_03_hfss3dlayout_export_3d_icepak(self, local_scratch, add_app): + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + ExportTo3DExtensionData, + ) + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + main, + ) aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder ) aedtapp.save_project(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_icepak.aedt")) - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main - - assert main({"is_test": True, "choice": "Export to Icepak"}) + assert main(ExportTo3DExtensionData(choice="Export to Icepak")) assert os.path.isfile(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_icepak_IPK.aedt")) aedtapp.close_project(os.path.basename(aedtapp.project_file[:-5]) + "_IPK") aedtapp.close_project(aedtapp.project_name) def test_03_hfss3dlayout_export_3d_maxwell(self, local_scratch, add_app): + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + ExportTo3DExtensionData, + ) + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( + main, + ) aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder ) aedtapp.save_project(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_maxwell.aedt")) - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main - - assert main({"is_test": True, "choice": "Export to Maxwell 3D"}) + assert main(ExportTo3DExtensionData(choice="Export to Maxwell 3D")) assert os.path.isfile(os.path.join(local_scratch.path, "test_03_hfss3dlayout_export_3d_maxwell_M3D.aedt")) aedtapp.close_project(os.path.basename(aedtapp.project_file[:-5]) + "_M3D") @@ -115,7 +131,9 @@ def test_03_hfss3dlayout_export_3d_maxwell(self, local_scratch, add_app): def test_04_project_report(self, add_app): aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name=report, subfolder=test_subfolder) - from ansys.aedt.core.extensions.project.create_report import main + from ansys.aedt.core.extensions.project.create_report import ( + main, + ) assert main({"is_test": True}) @@ -125,7 +143,9 @@ def test_04_project_report(self, add_app): def test_06_project_import_stl(self, add_app, local_scratch): aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_stl") - from ansys.aedt.core.extensions.project.import_nastran import main + from ansys.aedt.core.extensions.project.import_nastran import ( + main, + ) file_path = shutil.copy( os.path.join(local_path, "example_models", "T20", "sphere.stl"), @@ -143,14 +163,18 @@ def test_07_twinbuilder_convert_circuit(self, add_app): application=ansys.aedt.core.TwinBuilder, project_name=twinbuilder_circuit, subfolder=test_subfolder ) - from ansys.aedt.core.extensions.twinbuilder.convert_to_circuit import main + from ansys.aedt.core.extensions.twinbuilder.convert_to_circuit import ( + main, + ) assert main({"is_test": True}) aedtapp.close_project() def test_08_configure_a3d(self, local_scratch): - from ansys.aedt.core.extensions.project.configure_edb import main + from ansys.aedt.core.extensions.project.configure_edb import ( + main, + ) configuration_path = shutil.copy( os.path.join(extensions_local_path, "example_models", "T45", "ports.json"), @@ -202,7 +226,9 @@ def test_08_configure_a3d(self, local_scratch): ) def test_10_push_excitation_3dl(self, local_scratch, desktop): - from ansys.aedt.core.extensions.hfss3dlayout.push_excitation_from_file_3dl import main + from ansys.aedt.core.extensions.hfss3dlayout.push_excitation_from_file_3dl import ( + main, + ) project_path = shutil.copy( os.path.join(local_path, "example_models", "T41", "test_post_3d_layout_solved_23R2.aedtz"), @@ -224,7 +250,9 @@ def test_10_push_excitation_3dl(self, local_scratch, desktop): h3d.close_project(h3d.project_name) def test_12_export_layout(self, add_app): - from ansys.aedt.core.extensions.hfss3dlayout.export_layout import main + from ansys.aedt.core.extensions.hfss3dlayout.export_layout import ( + main, + ) app = add_app("ANSYS-HSD_V1", application=ansys.aedt.core.Hfss3dLayout, subfolder=test_subfolder) @@ -232,7 +260,9 @@ def test_12_export_layout(self, add_app): app.close_project() def test_13_parametrize_layout(self, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.parametrize_edb import main + from ansys.aedt.core.extensions.hfss3dlayout.parametrize_edb import ( + main, + ) file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_param.aedb") @@ -259,7 +289,9 @@ def test_13_parametrize_layout(self, local_scratch): def test_15_import_asc(self, local_scratch, add_app): aedtapp = add_app("Circuit", application=ansys.aedt.core.Circuit) - from ansys.aedt.core.extensions.circuit.import_schematic import main + from ansys.aedt.core.extensions.circuit.import_schematic import ( + main, + ) file_path = os.path.join(local_path, "example_models", "T21", "butter.asc") assert main({"is_test": True, "asc_file": file_path}) @@ -280,7 +312,9 @@ def test_15_import_asc(self, local_scratch, add_app): def test_16_arbitrary_waveport(self, local_scratch): import tempfile - from ansys.aedt.core.extensions.hfss3dlayout.generate_arbitrary_wave_ports import main + from ansys.aedt.core.extensions.hfss3dlayout.generate_arbitrary_wave_ports import ( + main, + ) file_path = os.path.join(local_scratch.path, "waveport.aedb") @@ -297,7 +331,9 @@ def test_16_arbitrary_waveport(self, local_scratch): temp_dir.cleanup() def test_17_choke_designer(self, local_scratch): - from ansys.aedt.core.extensions.hfss.choke_designer import main + from ansys.aedt.core.extensions.hfss.choke_designer import ( + main, + ) choke_config = { "Number of Windings": {"1": True, "2": False, "3": False, "4": False}, @@ -335,7 +371,9 @@ def test_17_choke_designer(self, local_scratch): @pytest.mark.skipif(is_linux, reason="Not supported in Linux.") def test_18_via_merging(self, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.via_clustering_extension import main + from ansys.aedt.core.extensions.hfss3dlayout.via_clustering_extension import ( + main, + ) file_path = os.path.join(local_scratch.path, "test_via_merging.aedb") new_file = os.path.join(local_scratch.path, "new_test_via_merging.aedb") @@ -358,7 +396,9 @@ def test_18_via_merging(self, local_scratch): def test_19_shielding_effectiveness(self, add_app, local_scratch): aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name="se") - from ansys.aedt.core.extensions.hfss.shielding_effectiveness import main + from ansys.aedt.core.extensions.hfss.shielding_effectiveness import ( + main, + ) assert not main( { @@ -398,7 +438,9 @@ def test_19_shielding_effectiveness(self, add_app, local_scratch): aedtapp.close_project(aedtapp.project_name) def test_fields_distribution(self, add_app, local_scratch): - from ansys.aedt.core.extensions.maxwell3d.fields_distribution import main + from ansys.aedt.core.extensions.maxwell3d.fields_distribution import ( + main, + ) file_path = os.path.join(local_scratch.path, "loss_distribution.csv") @@ -484,7 +526,9 @@ def test_fields_distribution(self, add_app, local_scratch): @pytest.mark.skipif(is_linux, reason="Not Supported on Linux.") def test_layout_design_toolkit_antipad_1(self, add_app, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import BackendAntipad + from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import ( + BackendAntipad, + ) file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_antipad_1.aedb") @@ -500,7 +544,9 @@ def test_layout_design_toolkit_antipad_1(self, add_app, local_scratch): @pytest.mark.skipif(is_linux, reason="Not Supported on Linux.") def test_layout_design_toolkit_antipad_2(self, add_app, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import BackendAntipad + from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import ( + BackendAntipad, + ) file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_antipad_2.aedb") @@ -518,7 +564,9 @@ def test_layout_design_toolkit_antipad_2(self, add_app, local_scratch): @pytest.mark.skipif(is_linux, reason="Not Supported on Linux.") def test_layout_design_toolkit_micro_via(self, add_app, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import BackendMircoVia + from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import ( + BackendMircoVia, + ) file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_antipad_3.aedb") @@ -535,7 +583,9 @@ def test_layout_design_toolkit_micro_via(self, add_app, local_scratch): h3d.close_project() def test_citcuit_configuration(self, local_scratch): - from ansys.aedt.core.extensions.circuit.circuit_configuration import main + from ansys.aedt.core.extensions.circuit.circuit_configuration import ( + main, + ) file_path = os.path.join(local_scratch.path, "config.aedt") From 624f4f5cd36a2970e47c8cee121724f7ab98879a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 14:52:15 +0000 Subject: [PATCH 12/12] CHORE: Auto fixes from pre-commit hooks --- tests/system/extensions/test_45_extensions.py | 102 +++++------------- 1 file changed, 27 insertions(+), 75 deletions(-) diff --git a/tests/system/extensions/test_45_extensions.py b/tests/system/extensions/test_45_extensions.py index 566c77c496f..719b33ca538 100644 --- a/tests/system/extensions/test_45_extensions.py +++ b/tests/system/extensions/test_45_extensions.py @@ -29,9 +29,7 @@ import ansys.aedt.core from ansys.aedt.core.generic.settings import is_linux -from tests.system.extensions.conftest import ( - local_path as extensions_local_path, -) +from tests.system.extensions.conftest import local_path as extensions_local_path from tests.system.general.conftest import local_path push_project = "push_excitation" @@ -54,9 +52,7 @@ def init(self, desktop): def test_02_hfss_push(self, add_app): aedtapp = add_app(project_name=push_project, subfolder=test_subfolder) - from ansys.aedt.core.extensions.hfss.push_excitation_from_file import ( - main, - ) + from ansys.aedt.core.extensions.hfss.push_excitation_from_file import main # No choice file_path = os.path.join(local_path, "example_models", "T20", "Sinusoidal.csv") @@ -71,12 +67,8 @@ def test_02_hfss_push(self, add_app): aedtapp.close_project(aedtapp.project_name) def test_03_hfss3dlayout_export_3d_q3d(self, local_scratch, add_app): - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - ExportTo3DExtensionData, - ) - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder @@ -91,12 +83,9 @@ def test_03_hfss3dlayout_export_3d_q3d(self, local_scratch, add_app): aedtapp.close_project(aedtapp.project_name) def test_03_hfss3dlayout_export_3d_icepak(self, local_scratch, add_app): - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - ExportTo3DExtensionData, - ) - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main + aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder ) @@ -110,12 +99,9 @@ def test_03_hfss3dlayout_export_3d_icepak(self, local_scratch, add_app): aedtapp.close_project(aedtapp.project_name) def test_03_hfss3dlayout_export_3d_maxwell(self, local_scratch, add_app): - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - ExportTo3DExtensionData, - ) - from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import ExportTo3DExtensionData + from ansys.aedt.core.extensions.hfss3dlayout.export_to_3d import main + aedtapp = add_app( application=ansys.aedt.core.Hfss3dLayout, project_name=export_3d_project, subfolder=test_subfolder ) @@ -131,9 +117,7 @@ def test_03_hfss3dlayout_export_3d_maxwell(self, local_scratch, add_app): def test_04_project_report(self, add_app): aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name=report, subfolder=test_subfolder) - from ansys.aedt.core.extensions.project.create_report import ( - main, - ) + from ansys.aedt.core.extensions.project.create_report import main assert main({"is_test": True}) @@ -143,9 +127,7 @@ def test_04_project_report(self, add_app): def test_06_project_import_stl(self, add_app, local_scratch): aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_stl") - from ansys.aedt.core.extensions.project.import_nastran import ( - main, - ) + from ansys.aedt.core.extensions.project.import_nastran import main file_path = shutil.copy( os.path.join(local_path, "example_models", "T20", "sphere.stl"), @@ -163,18 +145,14 @@ def test_07_twinbuilder_convert_circuit(self, add_app): application=ansys.aedt.core.TwinBuilder, project_name=twinbuilder_circuit, subfolder=test_subfolder ) - from ansys.aedt.core.extensions.twinbuilder.convert_to_circuit import ( - main, - ) + from ansys.aedt.core.extensions.twinbuilder.convert_to_circuit import main assert main({"is_test": True}) aedtapp.close_project() def test_08_configure_a3d(self, local_scratch): - from ansys.aedt.core.extensions.project.configure_edb import ( - main, - ) + from ansys.aedt.core.extensions.project.configure_edb import main configuration_path = shutil.copy( os.path.join(extensions_local_path, "example_models", "T45", "ports.json"), @@ -226,9 +204,7 @@ def test_08_configure_a3d(self, local_scratch): ) def test_10_push_excitation_3dl(self, local_scratch, desktop): - from ansys.aedt.core.extensions.hfss3dlayout.push_excitation_from_file_3dl import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.push_excitation_from_file_3dl import main project_path = shutil.copy( os.path.join(local_path, "example_models", "T41", "test_post_3d_layout_solved_23R2.aedtz"), @@ -250,9 +226,7 @@ def test_10_push_excitation_3dl(self, local_scratch, desktop): h3d.close_project(h3d.project_name) def test_12_export_layout(self, add_app): - from ansys.aedt.core.extensions.hfss3dlayout.export_layout import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.export_layout import main app = add_app("ANSYS-HSD_V1", application=ansys.aedt.core.Hfss3dLayout, subfolder=test_subfolder) @@ -260,9 +234,7 @@ def test_12_export_layout(self, add_app): app.close_project() def test_13_parametrize_layout(self, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.parametrize_edb import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.parametrize_edb import main file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_param.aedb") @@ -289,9 +261,7 @@ def test_13_parametrize_layout(self, local_scratch): def test_15_import_asc(self, local_scratch, add_app): aedtapp = add_app("Circuit", application=ansys.aedt.core.Circuit) - from ansys.aedt.core.extensions.circuit.import_schematic import ( - main, - ) + from ansys.aedt.core.extensions.circuit.import_schematic import main file_path = os.path.join(local_path, "example_models", "T21", "butter.asc") assert main({"is_test": True, "asc_file": file_path}) @@ -312,9 +282,7 @@ def test_15_import_asc(self, local_scratch, add_app): def test_16_arbitrary_waveport(self, local_scratch): import tempfile - from ansys.aedt.core.extensions.hfss3dlayout.generate_arbitrary_wave_ports import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.generate_arbitrary_wave_ports import main file_path = os.path.join(local_scratch.path, "waveport.aedb") @@ -331,9 +299,7 @@ def test_16_arbitrary_waveport(self, local_scratch): temp_dir.cleanup() def test_17_choke_designer(self, local_scratch): - from ansys.aedt.core.extensions.hfss.choke_designer import ( - main, - ) + from ansys.aedt.core.extensions.hfss.choke_designer import main choke_config = { "Number of Windings": {"1": True, "2": False, "3": False, "4": False}, @@ -371,9 +337,7 @@ def test_17_choke_designer(self, local_scratch): @pytest.mark.skipif(is_linux, reason="Not supported in Linux.") def test_18_via_merging(self, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.via_clustering_extension import ( - main, - ) + from ansys.aedt.core.extensions.hfss3dlayout.via_clustering_extension import main file_path = os.path.join(local_scratch.path, "test_via_merging.aedb") new_file = os.path.join(local_scratch.path, "new_test_via_merging.aedb") @@ -396,9 +360,7 @@ def test_18_via_merging(self, local_scratch): def test_19_shielding_effectiveness(self, add_app, local_scratch): aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name="se") - from ansys.aedt.core.extensions.hfss.shielding_effectiveness import ( - main, - ) + from ansys.aedt.core.extensions.hfss.shielding_effectiveness import main assert not main( { @@ -438,9 +400,7 @@ def test_19_shielding_effectiveness(self, add_app, local_scratch): aedtapp.close_project(aedtapp.project_name) def test_fields_distribution(self, add_app, local_scratch): - from ansys.aedt.core.extensions.maxwell3d.fields_distribution import ( - main, - ) + from ansys.aedt.core.extensions.maxwell3d.fields_distribution import main file_path = os.path.join(local_scratch.path, "loss_distribution.csv") @@ -526,9 +486,7 @@ def test_fields_distribution(self, add_app, local_scratch): @pytest.mark.skipif(is_linux, reason="Not Supported on Linux.") def test_layout_design_toolkit_antipad_1(self, add_app, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import ( - BackendAntipad, - ) + from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import BackendAntipad file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_antipad_1.aedb") @@ -544,9 +502,7 @@ def test_layout_design_toolkit_antipad_1(self, add_app, local_scratch): @pytest.mark.skipif(is_linux, reason="Not Supported on Linux.") def test_layout_design_toolkit_antipad_2(self, add_app, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import ( - BackendAntipad, - ) + from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import BackendAntipad file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_antipad_2.aedb") @@ -564,9 +520,7 @@ def test_layout_design_toolkit_antipad_2(self, add_app, local_scratch): @pytest.mark.skipif(is_linux, reason="Not Supported on Linux.") def test_layout_design_toolkit_micro_via(self, add_app, local_scratch): - from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import ( - BackendMircoVia, - ) + from ansys.aedt.core.extensions.hfss3dlayout.post_layout_design_toolkit import BackendMircoVia file_path = os.path.join(local_scratch.path, "ANSYS-HSD_V1_antipad_3.aedb") @@ -583,9 +537,7 @@ def test_layout_design_toolkit_micro_via(self, add_app, local_scratch): h3d.close_project() def test_citcuit_configuration(self, local_scratch): - from ansys.aedt.core.extensions.circuit.circuit_configuration import ( - main, - ) + from ansys.aedt.core.extensions.circuit.circuit_configuration import main file_path = os.path.join(local_scratch.path, "config.aedt")