|
| 1 | +import copy |
| 2 | +from datetime import datetime as dt |
| 3 | + |
1 | 4 | import pytest |
2 | 5 | from PyQt6.QtCore import QModelIndex |
3 | 6 | from PyQt6.QtGui import QColor |
4 | 7 | from pytestqt.qt_compat import qt_api |
5 | 8 |
|
6 | | -from ert.ensemble_evaluator.state import COLOR_FAILED |
| 9 | +from ert.ensemble_evaluator.snapshot import ( |
| 10 | + EnsembleSnapshot, |
| 11 | + FMStepSnapshot, |
| 12 | + RealizationSnapshot, |
| 13 | +) |
| 14 | +from ert.ensemble_evaluator.state import ( |
| 15 | + COLOR_FAILED, |
| 16 | + FORWARD_MODEL_STATE_START, |
| 17 | + REALIZATION_STATE_RUNNING, |
| 18 | +) |
7 | 19 | from ert.gui.model.snapshot import FMStepColorHint, SnapshotModel |
8 | 20 |
|
9 | 21 | from .gui_models_utils import finish_snapshot |
10 | 22 |
|
11 | 23 |
|
| 24 | +@pytest.fixture |
| 25 | +def small_snapshot() -> EnsembleSnapshot: |
| 26 | + real = RealizationSnapshot( |
| 27 | + status=REALIZATION_STATE_RUNNING, |
| 28 | + active=True, |
| 29 | + exec_hosts="COMP-01", |
| 30 | + fm_steps={ |
| 31 | + "0": FMStepSnapshot( |
| 32 | + start_time=dt.now(), |
| 33 | + end_time=dt.now(), |
| 34 | + name="poly_eval", |
| 35 | + index="0", |
| 36 | + status=FORWARD_MODEL_STATE_START, |
| 37 | + error="error", |
| 38 | + stdout="std_out_file", |
| 39 | + stderr="std_err_file", |
| 40 | + current_memory_usage=123, |
| 41 | + max_memory_usage=312, |
| 42 | + ), |
| 43 | + "1": FMStepSnapshot( |
| 44 | + start_time=dt.now(), |
| 45 | + end_time=dt.now(), |
| 46 | + name="poly_postval", |
| 47 | + index="1", |
| 48 | + status=FORWARD_MODEL_STATE_START, |
| 49 | + error="error", |
| 50 | + stdout="std_out_file", |
| 51 | + stderr="std_err_file", |
| 52 | + current_memory_usage=123, |
| 53 | + max_memory_usage=312, |
| 54 | + ), |
| 55 | + }, |
| 56 | + ) |
| 57 | + snapshot = EnsembleSnapshot() |
| 58 | + for i in range(10): |
| 59 | + snapshot.add_realization(str(i), copy.deepcopy(real)) |
| 60 | + |
| 61 | + return snapshot |
| 62 | + |
| 63 | + |
12 | 64 | @pytest.mark.integration_test |
13 | 65 | @pytest.mark.skip_mac_ci # slow |
14 | | -def test_using_qt_model_tester(full_snapshot): |
| 66 | +def test_using_qt_model_tester(small_snapshot): |
15 | 67 | model = SnapshotModel() |
16 | 68 |
|
17 | 69 | reporting_mode = qt_api.QtTest.QAbstractItemModelTester.FailureReportingMode.Fatal |
18 | 70 | tester = qt_api.QtTest.QAbstractItemModelTester( # noqa: F841, prevent GC |
19 | 71 | model, reporting_mode |
20 | 72 | ) |
21 | 73 |
|
22 | | - model._add_snapshot(SnapshotModel.prerender(full_snapshot), "0") |
23 | | - model._add_snapshot(SnapshotModel.prerender(full_snapshot), "1") |
24 | | - snapshot = finish_snapshot(SnapshotModel.prerender(full_snapshot)) |
| 74 | + model._add_snapshot(SnapshotModel.prerender(small_snapshot), "0") |
| 75 | + model._add_snapshot(SnapshotModel.prerender(small_snapshot), "1") |
| 76 | + snapshot = finish_snapshot(SnapshotModel.prerender(small_snapshot)) |
25 | 77 | model._update_snapshot(SnapshotModel.prerender(snapshot), "0") |
26 | 78 | model._update_snapshot(SnapshotModel.prerender(snapshot), "1") |
27 | 79 |
|
|
0 commit comments