Skip to content

Commit b084394

Browse files
committed
TYP: Type annotate tests/test_units/test_prerealization_surfaces.py
1 parent 9feb714 commit b084394

1 file changed

Lines changed: 90 additions & 47 deletions

File tree

tests/test_units/test_prerealization_surfaces.py

Lines changed: 90 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
"""
1212

1313
import logging
14+
from pathlib import Path
15+
from typing import Any
1416

1517
import pytest
18+
import xtgeo
19+
from pytest import MonkeyPatch
1620

1721
from fmu import dataio
1822
from fmu.dataio import _utils as utils
@@ -23,8 +27,11 @@
2327

2428

2529
def test_regsurf_case_observation(
26-
fmurun_prehook, rmsglobalconfig, regsurf, monkeypatch: pytest.MonkeyPatch
27-
):
30+
fmurun_prehook: Path,
31+
rmsglobalconfig: dict[str, Any],
32+
regsurf: xtgeo.RegularSurface,
33+
monkeypatch: MonkeyPatch,
34+
) -> None:
2835
"""Test generating pre-realization surfaces that comes right to case.
2936
3037
Notice the difference between this use-case and the 'preprocessed' example later!
@@ -53,17 +60,24 @@ def test_regsurf_case_observation(
5360

5461

5562
def test_regsurf_preprocessed_observation(
56-
fmurun_prehook, rmssetup, rmsglobalconfig, regsurf, monkeypatch
57-
):
63+
fmurun_prehook: Path,
64+
rmssetup: Path,
65+
rmsglobalconfig: dict[str, Any],
66+
regsurf: xtgeo.RegularSurface,
67+
monkeypatch: MonkeyPatch,
68+
) -> None:
5869
"""Test generating pre-realization surfaces that comes to share/preprocessed.
5970
6071
Later, a fmu run will update this (merge metadata)
6172
"""
6273

6374
@pytest.mark.usefixtures("inside_rms_interactive")
6475
def _export_data_from_rms(
65-
rmssetup, rmsglobalconfig, regsurf, monkeypatch: pytest.MonkeyPatch
66-
):
76+
rmssetup: Path,
77+
rmsglobalconfig: dict[str, Any],
78+
regsurf: xtgeo.RegularSurface,
79+
monkeypatch: MonkeyPatch,
80+
) -> str:
6781
"""Run an export of a preprocessed surface inside RMS."""
6882
logger.info("Active folder is %s", rmssetup)
6983

@@ -74,7 +88,7 @@ def _export_data_from_rms(
7488
name="TopVolantis",
7589
content="depth",
7690
is_observation=True,
77-
timedata=[[20240802, "moni"], [20200909, "base"]],
91+
timedata=[["20240802", "moni"], ["20200909", "base"]],
7892
)
7993

8094
metadata = edata.generate_metadata(regsurf)
@@ -89,7 +103,9 @@ def _export_data_from_rms(
89103

90104
return edata.export(regsurf)
91105

92-
def _run_case_fmu(fmurun_prehook, surfacepath, monkeypatch: pytest.MonkeyPatch):
106+
def _run_case_fmu(
107+
fmurun_prehook: Path, surfacepath: str, monkeypatch: MonkeyPatch
108+
) -> None:
93109
"""Run FMU workflow, using the preprocessed data as case data.
94110
95111
When re-using metadata, the input object to dataio shall not be a XTGeo or
@@ -155,32 +171,32 @@ def _run_case_fmu(fmurun_prehook, surfacepath, monkeypatch: pytest.MonkeyPatch):
155171
],
156172
)
157173
def test_regsurf_preprocessed_filename_retained(
158-
fmurun_prehook,
159-
rmssetup,
160-
rmsglobalconfig,
161-
regsurf,
162-
parent,
163-
name,
164-
tagname,
165-
exproot,
166-
monkeypatch,
167-
):
174+
fmurun_prehook: Path,
175+
rmssetup: Path,
176+
rmsglobalconfig: dict[str, Any],
177+
regsurf: xtgeo.RegularSurface,
178+
parent: str,
179+
name: str,
180+
tagname: str,
181+
exproot: str,
182+
monkeypatch: MonkeyPatch,
183+
) -> None:
168184
"""
169185
Check that current name and/or tagname are propegated and
170186
retained when re-exporting preprocessed data.
171187
"""
172188

173189
@pytest.mark.usefixtures("inside_rms_interactive")
174190
def _export_data_from_rms(
175-
rmssetup,
176-
rmsglobalconfig,
177-
regsurf,
178-
parent,
179-
name,
180-
tagname,
181-
exproot,
182-
monkeypatch: pytest.MonkeyPatch,
183-
):
191+
rmssetup: Path,
192+
rmsglobalconfig: dict[str, Any],
193+
regsurf: xtgeo.RegularSurface,
194+
parent: str,
195+
name: str,
196+
tagname: str,
197+
exproot: str,
198+
monkeypatch: MonkeyPatch,
199+
) -> str:
184200
"""Run an export of a preprocessed surface inside RMS."""
185201
logger.info("Active folder is %s", rmssetup)
186202

@@ -190,7 +206,7 @@ def _export_data_from_rms(
190206
preprocessed=True,
191207
content="depth",
192208
parent=parent,
193-
timedata=[[20240802, "moni"], [20200909, "base"]],
209+
timedata=[["20240802", "moni"], ["20200909", "base"]],
194210
is_observation=True,
195211
name=name,
196212
tagname=tagname,
@@ -207,8 +223,11 @@ def _export_data_from_rms(
207223
return edata.export(regsurf)
208224

209225
def _run_case_fmu(
210-
fmurun_prehook, surfacepath, exproot, monkeypatch: pytest.MonkeyPatch
211-
):
226+
fmurun_prehook: Path,
227+
surfacepath: Any,
228+
exproot: str,
229+
monkeypatch: MonkeyPatch,
230+
) -> None:
212231
"""Run FMU workflow, using the preprocessed data on a subfolder."""
213232

214233
monkeypatch.chdir(fmurun_prehook)
@@ -233,8 +252,12 @@ def _run_case_fmu(
233252

234253

235254
def test_regsurf_preprocessed_observation_subfolder(
236-
fmurun_prehook, rmssetup, rmsglobalconfig, regsurf, monkeypatch
237-
):
255+
fmurun_prehook: Path,
256+
rmssetup: Path,
257+
rmsglobalconfig: dict[str, Any],
258+
regsurf: xtgeo.RegularSurface,
259+
monkeypatch: MonkeyPatch,
260+
) -> None:
238261
"""As previous test, but with data using subfolder option.
239262
240263
When the original output is using a subfolder key, the subsequent job shall detect
@@ -245,8 +268,11 @@ def test_regsurf_preprocessed_observation_subfolder(
245268

246269
@pytest.mark.usefixtures("inside_rms_interactive")
247270
def _export_data_from_rms(
248-
rmssetup, rmsglobalconfig, regsurf, monkeypatch: pytest.MonkeyPatch
249-
):
271+
rmssetup: Path,
272+
rmsglobalconfig: dict[str, Any],
273+
regsurf: xtgeo.RegularSurface,
274+
monkeypatch: MonkeyPatch,
275+
) -> str:
250276
"""Run an export of a preprocessed surface inside RMS."""
251277
logger.info("Active folder is %s", rmssetup)
252278

@@ -257,7 +283,7 @@ def _export_data_from_rms(
257283
name="preprocessedmap",
258284
content="depth",
259285
is_observation=True,
260-
timedata=[[20240802, "moni"], [20200909, "base"]],
286+
timedata=[["20240802", "moni"], ["20200909", "base"]],
261287
subfolder="mysub",
262288
)
263289

@@ -271,7 +297,9 @@ def _export_data_from_rms(
271297

272298
return edata.export(regsurf)
273299

274-
def _run_case_fmu(fmurun_prehook, surfacepath, monkeypatch: pytest.MonkeyPatch):
300+
def _run_case_fmu(
301+
fmurun_prehook: Path, surfacepath: Any, monkeypatch: MonkeyPatch
302+
) -> None:
275303
"""Run FMU workflow, using the preprocessed data on a subfolder."""
276304

277305
monkeypatch.chdir(fmurun_prehook)
@@ -298,8 +326,11 @@ def _run_case_fmu(fmurun_prehook, surfacepath, monkeypatch: pytest.MonkeyPatch):
298326

299327
@pytest.mark.usefixtures("inside_rms_interactive")
300328
def test_preprocessed_with_abs_forcefolder_shall_fail(
301-
rmssetup, rmsglobalconfig, regsurf, monkeypatch: pytest.MonkeyPatch
302-
):
329+
rmssetup: Path,
330+
rmsglobalconfig: dict[str, Any],
331+
regsurf: xtgeo.RegularSurface,
332+
monkeypatch: MonkeyPatch,
333+
) -> None:
303334
"""Run an export of a preprocessed surface inside RMS, with absolute forcefolder."""
304335
logger.info("Active folder is %s", rmssetup)
305336

@@ -310,7 +341,7 @@ def test_preprocessed_with_abs_forcefolder_shall_fail(
310341
name="some",
311342
content="depth",
312343
is_observation=True,
313-
timedata=[[20240802, "moni"], [20200909, "base"]],
344+
timedata=[["20240802", "moni"], ["20200909", "base"]],
314345
forcefolder="/tmp",
315346
)
316347

@@ -320,8 +351,11 @@ def test_preprocessed_with_abs_forcefolder_shall_fail(
320351

321352
@pytest.mark.usefixtures("inside_rms_interactive")
322353
def test_preprocessed_with_rel_forcefolder_ok(
323-
rmssetup, rmsglobalconfig, regsurf, monkeypatch: pytest.MonkeyPatch
324-
):
354+
rmssetup: Path,
355+
rmsglobalconfig: dict[str, Any],
356+
regsurf: xtgeo.RegularSurface,
357+
monkeypatch: MonkeyPatch,
358+
) -> None:
325359
"""Run an export of a preprocessed surface inside RMS, with forcefolder."""
326360
logger.info("Active folder is %s", rmssetup)
327361

@@ -332,7 +366,7 @@ def test_preprocessed_with_rel_forcefolder_ok(
332366
name="some",
333367
content="depth",
334368
is_observation=True,
335-
timedata=[[20240802, "moni"], [20200909, "base"]],
369+
timedata=[["20240802", "moni"], ["20200909", "base"]],
336370
forcefolder="tmp",
337371
)
338372
meta = edata.generate_metadata(regsurf)
@@ -341,8 +375,12 @@ def test_preprocessed_with_rel_forcefolder_ok(
341375

342376

343377
def test_access_settings_retained(
344-
fmurun_prehook, rmssetup, rmsglobalconfig, regsurf, monkeypatch
345-
):
378+
fmurun_prehook: Path,
379+
rmssetup: Path,
380+
rmsglobalconfig: dict[str, Any],
381+
regsurf: xtgeo.RegularSurface,
382+
monkeypatch: MonkeyPatch,
383+
) -> None:
346384
"""Test that access level put on pre-processed data are retained when the
347385
metadata is being completed during later FMU run.
348386
@@ -351,8 +389,11 @@ def test_access_settings_retained(
351389

352390
@pytest.mark.usefixtures("inside_rms_interactive")
353391
def _export_data_from_rms(
354-
rmssetup, rmsglobalconfig, regsurf, monkeypatch: pytest.MonkeyPatch
355-
):
392+
rmssetup: Path,
393+
rmsglobalconfig: dict[str, Any],
394+
regsurf: xtgeo.RegularSurface,
395+
monkeypatch: MonkeyPatch,
396+
) -> str:
356397
"""Run an export of a preprocessed surface inside RMS."""
357398
logger.info("Active folder is %s", rmssetup)
358399

@@ -375,7 +416,9 @@ def _export_data_from_rms(
375416

376417
return edata.export(regsurf)
377418

378-
def _run_case_fmu(fmurun_prehook, surfacepath, monkeypatch: pytest.MonkeyPatch):
419+
def _run_case_fmu(
420+
fmurun_prehook: Path, surfacepath: Any, monkeypatch: MonkeyPatch
421+
) -> None:
379422
"""Run FMU workflow, test that access is retained from preprocessed."""
380423

381424
monkeypatch.chdir(fmurun_prehook)

0 commit comments

Comments
 (0)