Skip to content

Commit fd360c8

Browse files
committed
Add run_dialog label test
1 parent e88d5ff commit fd360c8

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

src/ert/gui/model/snapshot.py

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def _add_snapshot(self, snapshot: EnsembleSnapshot, iter_: str) -> None:
242242
data=RealNodeData(
243243
status=real.get("status"),
244244
active=real.get("active"),
245+
exec_hosts=real.get("exec_hosts"),
245246
fm_step_status_color_by_id=metadata.get(
246247
"aggr_fm_step_status_colors", defaultdict(None)
247248
)[real_id],

src/ert/gui/simulation/run_dialog.py

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def __init__(
219219
self._snapshot_model.rowsInserted.connect(self.on_snapshot_new_iteration)
220220

221221
self._fm_step_label = QLabel(self)
222+
self._fm_step_label.setObjectName("fm_step_label")
222223
self._fm_step_overview = FMStepOverview(self._snapshot_model, self)
223224

224225
self.running_time = QLabel("")

tests/ert/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def build(
3434
self,
3535
real_ids: Sequence[str],
3636
status: Optional[str],
37+
exec_hosts: Optional[str] = None,
3738
start_time: Optional[datetime] = None,
3839
end_time: Optional[datetime] = None,
3940
) -> EnsembleSnapshot:
@@ -49,6 +50,7 @@ def build(
4950
fm_steps=deepcopy(self.fm_steps),
5051
start_time=start_time,
5152
end_time=end_time,
53+
exec_hosts=exec_hosts,
5254
status=status,
5355
),
5456
)

tests/ert/unit_tests/gui/simulation/test_run_dialog.py

+100-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
from pytestqt.qtbot import QtBot
77
from qtpy import QtWidgets
88
from qtpy.QtCore import Qt, QTimer
9-
from qtpy.QtWidgets import QApplication, QComboBox, QPushButton, QToolButton, QWidget
9+
from qtpy.QtWidgets import (
10+
QApplication,
11+
QComboBox,
12+
QLabel,
13+
QPushButton,
14+
QToolButton,
15+
QWidget,
16+
)
1017

1118
import ert
1219
from ert.config import ErtConfig
@@ -459,6 +466,98 @@ def test_run_dialog_memory_usage_showing(
459466
assert max_memory_value == "60.00 KB"
460467

461468

469+
@pytest.mark.parametrize(
470+
"events, tab_widget_count, expected_host_info",
471+
[
472+
pytest.param(
473+
[
474+
FullSnapshotEvent(
475+
snapshot=(
476+
SnapshotBuilder()
477+
.add_fm_step(
478+
fm_step_id="0",
479+
index="0",
480+
name="fm_step_0",
481+
status=state.FORWARD_MODEL_STATE_START,
482+
)
483+
.build(
484+
["0"],
485+
status=state.REALIZATION_STATE_UNKNOWN,
486+
exec_hosts="COMP_01",
487+
)
488+
),
489+
iteration_label="Foo",
490+
current_iteration=0,
491+
total_iterations=1,
492+
progress=0.25,
493+
realization_count=4,
494+
status_count={"Finished": 1, "Pending": 1, "Unknown": 2},
495+
iteration=0,
496+
),
497+
EndEvent(failed=False, msg=""),
498+
],
499+
1,
500+
", assigned to host: COMP_01",
501+
id="Simulation where exec_host present",
502+
),
503+
pytest.param(
504+
[
505+
FullSnapshotEvent(
506+
snapshot=(
507+
SnapshotBuilder()
508+
.add_fm_step(
509+
fm_step_id="0",
510+
index="0",
511+
name="fm_step_0",
512+
status=state.FORWARD_MODEL_STATE_START,
513+
)
514+
.build(["0"], status=state.REALIZATION_STATE_UNKNOWN)
515+
),
516+
iteration_label="Foo",
517+
current_iteration=0,
518+
total_iterations=1,
519+
progress=0.25,
520+
realization_count=4,
521+
status_count={"Finished": 1, "Pending": 1, "Unknown": 2},
522+
iteration=0,
523+
),
524+
EndEvent(failed=False, msg=""),
525+
],
526+
1,
527+
"",
528+
id="Simulation where exec_host not present",
529+
),
530+
],
531+
)
532+
def test_run_dialog_fm_label_show_correct_info(
533+
events, tab_widget_count, expected_host_info, qtbot: QtBot, event_queue, run_dialog
534+
):
535+
run_dialog.run_experiment()
536+
for event in events:
537+
event_queue.put(event)
538+
539+
qtbot.waitUntil(
540+
lambda: run_dialog._tab_widget.count() == tab_widget_count, timeout=5000
541+
)
542+
qtbot.waitUntil(lambda: not run_dialog.done_button.isHidden(), timeout=5000)
543+
544+
# This is the container of realization boxes
545+
realization_box = run_dialog._tab_widget.widget(0)
546+
assert type(realization_box) == RealizationWidget
547+
# Click the first realization box
548+
qtbot.mouseClick(realization_box, Qt.LeftButton)
549+
fm_step_model = run_dialog._fm_step_overview.model()
550+
assert fm_step_model._real == 0
551+
552+
fm_step_label = run_dialog.findChild(QLabel, name="fm_step_label")
553+
assert not fm_step_label.text()
554+
555+
realization_box._item_clicked(run_dialog._fm_step_overview.model().index(0, 0))
556+
assert (
557+
fm_step_label.text() == f"Realization id 0 in iteration 0{expected_host_info}"
558+
)
559+
560+
462561
@pytest.mark.integration_test
463562
@pytest.mark.usefixtures("use_tmpdir")
464563
def test_that_exception_in_base_run_model_is_handled(qtbot: QtBot, storage):

0 commit comments

Comments
 (0)