|
6 | 6 | from pytestqt.qtbot import QtBot
|
7 | 7 | from qtpy import QtWidgets
|
8 | 8 | 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 | +) |
10 | 17 |
|
11 | 18 | import ert
|
12 | 19 | from ert.config import ErtConfig
|
@@ -459,6 +466,98 @@ def test_run_dialog_memory_usage_showing(
|
459 | 466 | assert max_memory_value == "60.00 KB"
|
460 | 467 |
|
461 | 468 |
|
| 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 | + |
462 | 561 | @pytest.mark.integration_test
|
463 | 562 | @pytest.mark.usefixtures("use_tmpdir")
|
464 | 563 | def test_that_exception_in_base_run_model_is_handled(qtbot: QtBot, storage):
|
|
0 commit comments