Skip to content

Commit 3e82a02

Browse files
committed
TESTS: Add system tests
1 parent 407d07c commit 3e82a02

File tree

2 files changed

+115
-20
lines changed

2 files changed

+115
-20
lines changed

tests/system/extensions/test_45_extensions.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,6 @@ def init(self, desktop):
5353
os.environ["PYAEDT_SCRIPT_PORT"] = str(desktop.port)
5454
os.environ["PYAEDT_SCRIPT_VERSION"] = desktop.aedt_version_id
5555

56-
def test_01_template(self, add_app):
57-
aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_test")
58-
59-
from ansys.aedt.core.extensions.templates.template_get_started import main
60-
61-
assert main({"is_test": True, "origin_x": 2})
62-
assert len(aedtapp.modeler.object_list) == 1
63-
64-
aedtapp2 = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_test2")
65-
aedtapp2.save_project()
66-
file_path = str(aedtapp2.project_file)
67-
pname = aedtapp2.project_name
68-
aedtapp2.close_project()
69-
70-
assert main({"is_test": True, "file_path": file_path})
71-
assert len(aedtapp.project_list) == 2
72-
73-
aedtapp.close_project(pname)
74-
aedtapp.close_project(aedtapp.project_name)
75-
7656
def test_02_hfss_push(self, add_app):
7757
aedtapp = add_app(project_name=push_project, subfolder=test_subfolder)
7858

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
4+
# SPDX-License-Identifier: MIT
5+
#
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
25+
from dataclasses import asdict
26+
from pathlib import Path
27+
import tkinter
28+
from tkinter import ttk
29+
from unittest.mock import MagicMock
30+
from unittest.mock import patch
31+
32+
import pytest
33+
34+
from ansys.aedt.core import Hfss
35+
from ansys.aedt.core.extensions.misc import MOON
36+
from ansys.aedt.core.extensions.misc import NO_ACTIVE_PROJECT
37+
from ansys.aedt.core.extensions.misc import SUN
38+
from ansys.aedt.core.extensions.misc import ExtensionCommon
39+
from ansys.aedt.core.extensions.misc import ExtensionTheme
40+
from ansys.aedt.core.extensions.templates.template_get_started import EXTENSION_TITLE
41+
from ansys.aedt.core.extensions.templates.template_get_started import ExtensionData
42+
from ansys.aedt.core.extensions.templates.template_get_started import TemplateExtension
43+
from ansys.aedt.core.generic.design_types import get_pyaedt_app
44+
45+
# MOCK_PATH = "/mock/path/file.aedt"
46+
# aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_test")
47+
48+
# from ansys.aedt.core.extensions.templates.template_get_started import main
49+
50+
# assert main({"is_test": True, "origin_x": 2})
51+
# assert len(aedtapp.modeler.object_list) == 1
52+
53+
# aedtapp2 = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_test2")
54+
# aedtapp2.save_project()
55+
# file_path = str(aedtapp2.project_file)
56+
# pname = aedtapp2.project_name
57+
# aedtapp2.close_project()
58+
59+
# assert main({"is_test": True, "file_path": file_path})
60+
# assert len(aedtapp.project_list) == 2
61+
62+
# aedtapp.close_project(pname)
63+
# aedtapp.close_project(aedtapp.project_name)
64+
# COPY_NAS_PATH = Path(local_scratch.path, "test_cad.nas")
65+
66+
# def test_01_template(self, add_app):
67+
# aedtapp = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_test")
68+
69+
# from ansys.aedt.core.extensions.templates.template_get_started import main
70+
71+
# assert main({"is_test": True, "origin_x": 2})
72+
# assert len(aedtapp.modeler.object_list) == 1
73+
74+
# aedtapp2 = add_app(application=ansys.aedt.core.Hfss, project_name="workflow_test2")
75+
# aedtapp2.save_project()
76+
# file_path = str(aedtapp2.project_file)
77+
# pname = aedtapp2.project_name
78+
# aedtapp2.close_project()
79+
80+
# assert main({"is_test": True, "file_path": file_path})
81+
# assert len(aedtapp.project_list) == 2
82+
83+
# aedtapp.close_project(pname)
84+
# aedtapp.close_project(aedtapp.project_name)
85+
86+
87+
def test_create_sphere_success(add_app, local_scratch):
88+
"""Test that the extension works correctly when creating a sphere."""
89+
from ansys.aedt.core.extensions.templates.template_get_started import main
90+
91+
DATA = ExtensionData()
92+
aedtapp = add_app(application=Hfss, project_name="workflow_template_extension_sphere")
93+
94+
assert 0 == len(aedtapp.modeler.object_list)
95+
assert main(asdict(DATA))
96+
assert 1 == len(aedtapp.modeler.object_list)
97+
98+
aedtapp.close_project(aedtapp.project_name)
99+
100+
101+
def test_load_aedt_file_success(add_app, tmp_path):
102+
"""Test that the extension works correctly when creating a sphere."""
103+
from ansys.aedt.core.extensions.templates.template_get_started import main
104+
105+
AEDT_PATH = tmp_path / "workflow_template_extension.aedt"
106+
DATA = ExtensionData(file_path=AEDT_PATH)
107+
app_0 = add_app(application=Hfss, project_name="workflow_template_extension")
108+
_ = app_0.modeler.create_box([10, 10, 10], [20, 20, 20], "box", display_wireframe=True)
109+
path = app_0.project_file
110+
app_0.save_project(file_name=str(AEDT_PATH))
111+
app_0.close_project(app_0.project_name)
112+
113+
app_1 = add_app(application=Hfss, just_open=True, project_name=str(AEDT_PATH))
114+
assert main(asdict(DATA))
115+
assert "box" in app_1.modeler.object_list

0 commit comments

Comments
 (0)