-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of GUI tests for surrogate plugins
- Loading branch information
1 parent
183549a
commit bc5c7df
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
################################################################################# | ||
# FOQUS Copyright (c) 2012 - 2023, by the software owners: Oak Ridge Institute | ||
# for Science and Education (ORISE), TRIAD National Security, LLC., Lawrence | ||
# Livermore National Security, LLC., The Regents of the University of | ||
# California, through Lawrence Berkeley National Laboratory, Battelle Memorial | ||
# Institute, Pacific Northwest Division through Pacific Northwest National | ||
# Laboratory, Carnegie Mellon University, West Virginia University, Boston | ||
# University, the Trustees of Princeton University, The University of Texas at | ||
# Austin, URS Energy & Construction, Inc., et al. All rights reserved. | ||
# | ||
# Please see the file LICENSE.md for full copyright and license information, | ||
# respectively. This file is also available online at the URL | ||
# "https://github.com/CCSI-Toolset/FOQUS". | ||
################################################################################# | ||
|
||
from foqus_lib.gui.main.mainWindow import mainWindow | ||
from foqus_lib.gui.surrogate.surrogateFrame import surrogateFrame | ||
import pytest | ||
|
||
|
||
pytestmark = pytest.mark.gui | ||
|
||
|
||
@pytest.fixture(scope="class", params=["UQ/Rosenbrock.foqus"]) | ||
def flowsheet_session_file(foqus_examples_dir, request): | ||
return str(foqus_examples_dir / "test_files" / request.param) | ||
|
||
|
||
@pytest.fixture(scope="class") | ||
def frame(main_window, flowsheet_session_file, qtbot, request) -> surrogateFrame: | ||
qtbot.wait_for_window_shown(main_window) | ||
main_window.loadSessionFile(flowsheet_session_file, saveCurrent=False) | ||
main_window.surrogateAction.trigger() | ||
frame: surrogateFrame = main_window.surFrame | ||
request.cls.frame = frame | ||
return frame | ||
|
||
|
||
# @pytest.mark.usefixtures("setup_frame_blank") | ||
class TestFrame: | ||
frame: surrogateFrame | ||
|
||
# FIXME currently getting errors at the end of the test run | ||
# QBasicTimer::start: QBasicTimer can only be used with threads started with QThread | ||
# fish: Job 1, 'pytest --pyargs foqus_lib -m gu…' terminated by signal SIGSEGV (Address boundary error) | ||
# initially thought it was related with pytest.mark.parametrize being used, | ||
# but it's happening even after commenting it out | ||
# @pytest.mark.parametrize( | ||
# "name", | ||
# [ | ||
# "keras_nn", | ||
# # "ACOSSO", | ||
# ] | ||
# ) | ||
def test_run_surrogate( | ||
self, qtbot, frame, main_window: mainWindow, name: str = "keras_nn" | ||
): | ||
qtbot.focused = frame | ||
|
||
qtbot.using(combo_box="Tool:").set_option(name) | ||
|
||
for tab in [ | ||
"Data", | ||
"Method Settings", | ||
"Variables", | ||
"Execution", | ||
]: | ||
qtbot.select_tab(tab) | ||
run_button, stop_button = qtbot.locate(button=any, index=[0, 1]) | ||
run_button.click() | ||
|
||
def is_completed(): | ||
return ( | ||
"surrogate finished" in main_window.statusBar().currentMessage().lower() | ||
) | ||
|
||
qtbot.wait_until(is_completed, timeout=30_000) | ||
qtbot.wait(1_000) |