Skip to content

Commit

Permalink
fixup: removed some changes that were needed for pyside6 typing. remo…
Browse files Browse the repository at this point in the history
…ved some leftovers from testing
  • Loading branch information
JHolba committed Jan 24, 2025
1 parent 08893c8 commit 4585071
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/ert/gui/tools/manage_experiments/storage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> A
return None

return cast(ChildModel | Self, index.internalPointer()).data(
index, cast(Qt.ItemDataRole, role)
index, Qt.ItemDataRole(role)
)

@override
Expand Down
8 changes: 0 additions & 8 deletions tests/ert/ui_tests/gui/test_manage_experiments_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ def test_that_init_updates_the_info_tab(qtbot, storage):
)

html_edit = tool.findChild(QTextEdit, name="ensemble_state_text")
assert type(html_edit) is QTextEdit
assert not html_edit.toPlainText()

# select the created ensemble
storage_widget = tool.findChild(StorageWidget)
assert type(storage_widget) is StorageWidget
storage_widget._tree_view.expandAll()
model_index = storage_widget._tree_view.model().index(
0, 0, storage_widget._tree_view.model().index(0, 0)
Expand All @@ -94,7 +92,6 @@ def test_that_init_updates_the_info_tab(qtbot, storage):

# select the correct tab
ensemble_widget = tool.findChild(_EnsembleWidget)
assert type(ensemble_widget) is _EnsembleWidget
ensemble_widget._currentTabChanged(1)

assert "UNDEFINED" in html_edit.toPlainText()
Expand Down Expand Up @@ -144,7 +141,6 @@ def test_experiment_view(

# select the experiment
storage_widget = tool.findChild(StorageWidget)
assert type(storage_widget) is StorageWidget
storage_widget._tree_view.expandAll()
model_index = storage_widget._tree_view.model().index(0, 0)
storage_widget._tree_view.setCurrentIndex(model_index)
Expand Down Expand Up @@ -177,7 +173,6 @@ def test_ensemble_view(

# select the ensemble
storage_widget = tool.findChild(StorageWidget)
assert type(storage_widget) is StorageWidget
storage_widget._tree_view.expandAll()
model_index = storage_widget._tree_view.model().index(
0, 0, storage_widget._tree_view.model().index(0, 0)
Expand Down Expand Up @@ -320,7 +315,6 @@ def _evaluate(coeffs, x):

# select the ensemble
storage_widget = tool.findChild(StorageWidget)
assert type(storage_widget) is StorageWidget
storage_widget._tree_view.expandAll()
model_index = storage_widget._tree_view.model().index(
0, 0, storage_widget._tree_view.model().index(0, 0)
Expand Down Expand Up @@ -386,7 +380,6 @@ def test_ensemble_observations_view_on_empty_ensemble(qtbot):

# select the ensemble
storage_widget = tool.findChild(StorageWidget)
assert type(storage_widget) is StorageWidget
storage_widget._tree_view.expandAll()
model_index = storage_widget._tree_view.model().index(
0, 0, storage_widget._tree_view.model().index(0, 0)
Expand Down Expand Up @@ -429,7 +422,6 @@ def test_realization_view(

# select the realization
storage_widget = tool.findChild(StorageWidget)
assert type(storage_widget) is StorageWidget
storage_widget._tree_view.expandAll()
model_index = storage_widget._tree_view.model().index(
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def panel_with_localization_on(qtbot: QtBot):
def func(settings, ensemble_size):
widget = AnalysisModuleVariablesPanel(settings, ensemble_size)
qtbot.addWidget(widget)
widget.show()
check_box = widget.findChild(QCheckBox, name="localization")
qtbot.mouseClick(check_box, Qt.MouseButton.LeftButton)
return settings, widget
Expand Down
55 changes: 19 additions & 36 deletions tests/ert/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from queue import SimpleQueue
from typing import cast
from unittest.mock import MagicMock, Mock, patch

import pandas as pd
Expand All @@ -14,7 +13,6 @@
QMessageBox,
QPushButton,
QToolButton,
QWidget,
)
from pytestqt.qtbot import QtBot

Expand Down Expand Up @@ -73,8 +71,6 @@ def notifier():
def run_dialog(qtbot: QtBot, run_model, event_queue, notifier):
run_dialog = RunDialog("mock.ert", run_model, event_queue, notifier)
qtbot.addWidget(run_dialog)
run_dialog.show()

yield run_dialog


Expand All @@ -85,9 +81,7 @@ def test_terminating_experiment_shows_a_confirmation_dialog(qtbot: QtBot, run_di

def handle_dialog():
terminate_dialog = wait_for_child(run_dialog, qtbot, QMessageBox)
dialog_buttons = cast(
QDialogButtonBox, terminate_dialog.findChild(QDialogButtonBox)
).buttons()
dialog_buttons = terminate_dialog.findChild(QDialogButtonBox).buttons()
yes_button = next(b for b in dialog_buttons if "Yes" in b.text())
qtbot.mouseClick(yes_button, Qt.MouseButton.LeftButton)

Expand Down Expand Up @@ -587,7 +581,7 @@ def handle_error_dialog(run_dialog):
assert "I failed :(" in text
qtbot.mouseClick(error_dialog.box.buttons()[0], Qt.MouseButton.LeftButton)

simulation_mode_combo = cast(QComboBox, gui.findChild(QComboBox))
simulation_mode_combo = gui.findChild(QComboBox)
simulation_mode_combo.setCurrentText("Single realization test-run")
qtbot.mouseClick(run_experiment, Qt.MouseButton.LeftButton)
run_dialog = wait_for_child(gui, qtbot, RunDialog)
Expand All @@ -611,20 +605,18 @@ def test_that_debug_info_button_provides_data_in_clipboard(qtbot: QtBot, storage
):
gui = _setup_main_window(ert_config, args_mock, GUILogHandler(), storage)
experiment_panel = gui.findChild(ExperimentPanel)
assert isinstance(experiment_panel, ExperimentPanel)
assert experiment_panel

run_experiment = experiment_panel.findChild(QWidget, name="run_experiment")
run_experiment = experiment_panel.findChild(QToolButton, name="run_experiment")
assert run_experiment
assert isinstance(run_experiment, QToolButton)

qtbot.mouseClick(run_experiment, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None, timeout=5000)
run_dialog = cast(RunDialog, gui.findChild(RunDialog))
assert run_dialog is not None
run_dialog = gui.findChild(RunDialog)
assert run_dialog
qtbot.waitUntil(lambda: run_dialog.is_simulation_done() == True, timeout=100000)
copy_debug_info_button = gui.findChild(QPushButton, "copy_debug_info_button")
assert copy_debug_info_button
assert isinstance(copy_debug_info_button, QPushButton)
qtbot.mouseClick(copy_debug_info_button, Qt.MouseButton.LeftButton)

clipboard_text = QApplication.clipboard().text()
Expand Down Expand Up @@ -654,34 +646,28 @@ def test_that_stdout_and_stderr_buttons_react_to_file_content(
):
gui = _setup_main_window(snake_oil_case, args_mock, GUILogHandler(), storage)
experiment_panel = gui.findChild(ExperimentPanel)

assert isinstance(experiment_panel, ExperimentPanel)
assert experiment_panel
simulation_mode_combo = experiment_panel.findChild(QComboBox)
assert isinstance(simulation_mode_combo, QComboBox)
assert simulation_mode_combo
simulation_mode_combo.setCurrentText(EnsembleExperiment.name())
simulation_settings = cast(
EnsembleExperimentPanel, gui.findChild(EnsembleExperimentPanel)
)
simulation_settings = gui.findChild(EnsembleExperimentPanel)
simulation_settings._experiment_name_field.setText("new_experiment_name")

run_experiment = experiment_panel.findChild(QWidget, name="run_experiment")
run_experiment = experiment_panel.findChild(QToolButton, name="run_experiment")
assert run_experiment
assert isinstance(run_experiment, QToolButton)

QTimer.singleShot(
1000, lambda: handle_run_path_dialog(gui, qtbot, delete_run_path=True)
)
qtbot.mouseClick(run_experiment, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None, timeout=5000)
run_dialog = cast(RunDialog, gui.findChild(RunDialog))
run_dialog = gui.findChild(RunDialog)

qtbot.waitUntil(lambda: run_dialog.is_simulation_done() == True, timeout=100000)

fm_step_overview = run_dialog._fm_step_overview
qtbot.waitUntil(lambda: not fm_step_overview.isHidden(), timeout=20000)
realization_widget = cast(
RealizationWidget, run_dialog.findChild(RealizationWidget)
)
realization_widget = run_dialog.findChild(RealizationWidget)

click_pos = realization_widget._real_view.rectForIndex(
realization_widget._real_list_model.index(0, 0)
Expand Down Expand Up @@ -710,7 +696,7 @@ def test_that_stdout_and_stderr_buttons_react_to_file_content(
qtbot.mouseClick(
fm_step_overview.viewport(), Qt.MouseButton.LeftButton, pos=click_pos
)
file_dialog = cast(FileDialog, run_dialog.findChild(FileDialog))
file_dialog = run_dialog.findChild(FileDialog)
qtbot.waitUntil(file_dialog.isVisible, timeout=10000)
file_dialog.close()

Expand Down Expand Up @@ -755,21 +741,18 @@ def test_that_design_matrix_show_parameters_button_is_visible(
):
gui = _setup_main_window(ert_config, args_mock, GUILogHandler(), storage)
experiment_panel = gui.findChild(ExperimentPanel)
assert isinstance(experiment_panel, ExperimentPanel)
assert experiment_panel

simulation_mode_combo = experiment_panel.findChild(QComboBox)
assert isinstance(simulation_mode_combo, QComboBox)
assert simulation_mode_combo

simulation_mode_combo.setCurrentText(EnsembleExperiment.name())
simulation_settings = cast(
EnsembleExperimentPanel, gui.findChild(EnsembleExperimentPanel)
)
show_dm_parameters = cast(
QPushButton,
simulation_settings.findChild(QPushButton, "show-dm-parameters"),
simulation_settings = gui.findChild(EnsembleExperimentPanel)
show_dm_parameters = simulation_settings.findChild(
QPushButton, "show-dm-parameters"
)
if design_matrix_entry:
assert isinstance(show_dm_parameters, QPushButton)
assert show_dm_parameters
else:
assert show_dm_parameters is None

Expand Down

0 comments on commit 4585071

Please sign in to comment.