Skip to content

Commit e3fcd77

Browse files
committed
Downsize snapshot in model test
1 parent fa1a3c5 commit e3fcd77

File tree

1 file changed

+57
-5
lines changed

1 file changed

+57
-5
lines changed

tests/ert/unit_tests/gui/model/test_snapshot.py

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,79 @@
1+
import copy
2+
from datetime import datetime as dt
3+
14
import pytest
25
from PyQt6.QtCore import QModelIndex
36
from PyQt6.QtGui import QColor
47
from pytestqt.qt_compat import qt_api
58

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+
)
719
from ert.gui.model.snapshot import FMStepColorHint, SnapshotModel
820

921
from .gui_models_utils import finish_snapshot
1022

1123

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+
1264
@pytest.mark.integration_test
1365
@pytest.mark.skip_mac_ci # slow
14-
def test_using_qt_model_tester(full_snapshot):
66+
def test_using_qt_model_tester(small_snapshot):
1567
model = SnapshotModel()
1668

1769
reporting_mode = qt_api.QtTest.QAbstractItemModelTester.FailureReportingMode.Fatal
1870
tester = qt_api.QtTest.QAbstractItemModelTester( # noqa: F841, prevent GC
1971
model, reporting_mode
2072
)
2173

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))
2577
model._update_snapshot(SnapshotModel.prerender(snapshot), "0")
2678
model._update_snapshot(SnapshotModel.prerender(snapshot), "1")
2779

0 commit comments

Comments
 (0)