-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e4350d
commit 5b2b59d
Showing
5 changed files
with
171 additions
and
15 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
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
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
154 changes: 151 additions & 3 deletions
154
tests/unit_tests/gui/test_full_manual_update_workflow.py
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 |
---|---|---|
@@ -1,27 +1,175 @@ | ||
import contextlib | ||
import shutil | ||
|
||
import numpy as np | ||
from qtpy.QtCore import Qt, QTimer | ||
from qtpy.QtWidgets import QApplication, QComboBox, QMessageBox, QPushButton, QWidget | ||
from qtpy.QtWidgets import ( | ||
QApplication, | ||
QCheckBox, | ||
QComboBox, | ||
QMessageBox, | ||
QPushButton, | ||
QWidget, | ||
) | ||
|
||
from ert.data import MeasuredData | ||
from ert.gui.ertwidgets.caselist import CaseList | ||
from ert.gui.simulation.ensemble_experiment_panel import EnsembleExperimentPanel | ||
from ert.gui.simulation.run_dialog import RunDialog | ||
from ert.gui.simulation.simulation_panel import SimulationPanel | ||
from ert.gui.simulation.view import RealizationWidget | ||
from ert.run_models import EnsembleExperiment, ManualUpdate | ||
from ert.validation import rangestring_to_mask | ||
from tests.unit_tests.gui.simulation.test_run_path_dialog import handle_run_path_dialog | ||
|
||
from .conftest import get_child, wait_for_child, with_manage_tool | ||
|
||
|
||
def test_that_the_manual_analysis_tool_works( | ||
def test_that_the_manual_analysis_model_works( | ||
ensemble_experiment_has_run, opened_main_window, qtbot, run_experiment | ||
): | ||
"""This runs a full manual update workflow, first running ensemble experiment | ||
where some of the realizations fail, then doing an update followed by a evaluation. | ||
""" | ||
gui = opened_main_window | ||
with contextlib.suppress(FileNotFoundError): | ||
shutil.rmtree("poly_out") | ||
# Select correct experiment in the simulation panel | ||
simulation_panel = gui.findChild(SimulationPanel) | ||
assert isinstance(simulation_panel, SimulationPanel) | ||
simulation_mode_combo = simulation_panel.findChild(QComboBox) | ||
assert isinstance(simulation_mode_combo, QComboBox) | ||
simulation_mode_combo.setCurrentText(ManualUpdate.name()) | ||
|
||
update_panel = get_child(gui, QWidget, name="manual_update_panel") | ||
assert update_panel | ||
|
||
# Click start simulation and agree to the message | ||
start_simulation = simulation_panel.findChild(QWidget, name="start_simulation") | ||
|
||
def handle_dialog(): | ||
qtbot.mouseClick( | ||
wait_for_child(gui, qtbot, QMessageBox).buttons()[0], Qt.LeftButton | ||
) | ||
|
||
QTimer.singleShot( | ||
500, lambda: handle_run_path_dialog(gui, qtbot, delete_run_path=False) | ||
) | ||
|
||
QTimer.singleShot(500, handle_dialog) | ||
qtbot.mouseClick(start_simulation, Qt.LeftButton) | ||
|
||
# The Run dialog opens, click show details and wait until done appears | ||
# then click it | ||
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None) | ||
run_dialog = gui.findChild(RunDialog) | ||
|
||
qtbot.mouseClick(run_dialog.show_details_button, Qt.LeftButton) | ||
|
||
qtbot.waitUntil(run_dialog.done_button.isVisible, timeout=200000) | ||
qtbot.waitUntil(lambda: run_dialog._tab_widget.currentWidget() is not None) | ||
|
||
qtbot.mouseClick(run_dialog.done_button, Qt.LeftButton) | ||
|
||
|
||
def test_manual_update_with_ensemble_experiment( | ||
ensemble_experiment_has_run, opened_main_window, qtbot, run_experiment | ||
): | ||
"""This runs a full manual update workflow, first running ensemble experiment | ||
where some of the realizations fail, then doing an update before running an | ||
ensemble experiment again to calculate the forecast of the update. | ||
""" | ||
gui = opened_main_window | ||
run_experiment(ManualUpdate) | ||
with contextlib.suppress(FileNotFoundError): | ||
shutil.rmtree("poly_out") | ||
# Select correct experiment in the simulation panel | ||
simulation_panel = gui.findChild(SimulationPanel) | ||
assert isinstance(simulation_panel, SimulationPanel) | ||
simulation_mode_combo = simulation_panel.findChild(QComboBox) | ||
assert isinstance(simulation_mode_combo, QComboBox) | ||
simulation_mode_combo.setCurrentText(ManualUpdate.name()) | ||
|
||
update_panel = get_child(gui, QWidget, name="manual_update_panel") | ||
assert update_panel | ||
qtbot.waitUntil( | ||
lambda: gui.findChild(QCheckBox, name="evaluate_posterior") is not None | ||
) | ||
check_box = gui.findChild(QCheckBox, name="evaluate_posterior") | ||
check_box.setChecked(False) | ||
# Click start simulation and agree to the message | ||
start_simulation = simulation_panel.findChild(QWidget, name="start_simulation") | ||
|
||
def handle_dialog(): | ||
qtbot.mouseClick( | ||
wait_for_child(gui, qtbot, QMessageBox).buttons()[0], Qt.LeftButton | ||
) | ||
|
||
QTimer.singleShot( | ||
500, lambda: handle_run_path_dialog(gui, qtbot, delete_run_path=False) | ||
) | ||
|
||
QTimer.singleShot(500, handle_dialog) | ||
qtbot.mouseClick(start_simulation, Qt.LeftButton) | ||
|
||
# The Run dialog opens, click show details and wait until done appears | ||
# then click it | ||
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None) | ||
run_dialog = gui.findChild(RunDialog) | ||
|
||
qtbot.mouseClick(run_dialog.show_details_button, Qt.LeftButton) | ||
|
||
qtbot.waitUntil(run_dialog.done_button.isVisible, timeout=200000) | ||
qtbot.waitUntil(lambda: run_dialog._tab_widget.currentWidget() is not None) | ||
|
||
qtbot.mouseClick(run_dialog.done_button, Qt.LeftButton) | ||
|
||
with contextlib.suppress(FileNotFoundError): | ||
shutil.rmtree("poly_out") | ||
# Select correct experiment in the simulation panel | ||
simulation_panel = gui.findChild(SimulationPanel) | ||
assert isinstance(simulation_panel, SimulationPanel) | ||
simulation_mode_combo = simulation_panel.findChild(QComboBox) | ||
assert isinstance(simulation_mode_combo, QComboBox) | ||
simulation_mode_combo.setCurrentText(EnsembleExperiment.name()) | ||
|
||
config_panel = get_child(gui, QWidget, name="Ensemble_experiment_panel") | ||
assert config_panel | ||
|
||
print(1) | ||
|
||
# Click start simulation and agree to the message | ||
start_simulation = simulation_panel.findChild(QWidget, name="start_simulation") | ||
|
||
def handle_dialog(): | ||
qtbot.mouseClick( | ||
wait_for_child(gui, qtbot, QMessageBox).buttons()[0], Qt.LeftButton | ||
) | ||
|
||
QTimer.singleShot( | ||
500, lambda: handle_run_path_dialog(gui, qtbot, delete_run_path=False) | ||
) | ||
|
||
QTimer.singleShot(500, handle_dialog) | ||
qtbot.mouseClick(start_simulation, Qt.LeftButton) | ||
|
||
# The Run dialog opens, click show details and wait until done appears | ||
# then click it | ||
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None) | ||
run_dialog = gui.findChild(RunDialog) | ||
|
||
qtbot.mouseClick(run_dialog.show_details_button, Qt.LeftButton) | ||
|
||
qtbot.waitUntil(run_dialog.done_button.isVisible, timeout=200000) | ||
qtbot.waitUntil(lambda: run_dialog._tab_widget.currentWidget() is not None) | ||
|
||
# Assert that the number of boxes in the detailed view is | ||
# equal to the number of realizations | ||
realization_widget = run_dialog._tab_widget.currentWidget() | ||
assert isinstance(realization_widget, RealizationWidget) | ||
list_model = realization_widget._real_view.model() | ||
assert ( | ||
list_model.rowCount() | ||
== simulation_panel.ert.ert_config.model_config.num_realizations | ||
) | ||
|
||
qtbot.mouseClick(run_dialog.done_button, Qt.LeftButton) |
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