From a22169edd99772f24b5fead4d1fb06e2781b400b Mon Sep 17 00:00:00 2001 From: mferrera Date: Thu, 6 Mar 2025 07:12:47 +0100 Subject: [PATCH] TST: Adapt Ert mode test to Ert 14 Ert 14.0.0 deprecated 'iterative ensemble smoother' mode. While this mode should also be removed from the Ert mode enum, we cannot do so safely within pinning the Ert version above 14. We cannot do that until we stop supporting Python 3.8. --- src/fmu/dataio/_models/fmu_results/enums.py | 2 ++ tests/test_units/test_fmuprovider_class.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/fmu/dataio/_models/fmu_results/enums.py b/src/fmu/dataio/_models/fmu_results/enums.py index b76a808de..0645aff7c 100644 --- a/src/fmu/dataio/_models/fmu_results/enums.py +++ b/src/fmu/dataio/_models/fmu_results/enums.py @@ -71,6 +71,8 @@ class ErtSimulationMode(str, Enum): ensemble_smoother = "ensemble_smoother" es_mda = "es_mda" evaluate_ensemble = "evaluate_ensemble" + # TODO: Remove 'iterative_ensemble_smoother' when Python 3.8 deprecated. It was + # removed # with Ert 14.0.0. iterative_ensemble_smoother = "iterative_ensemble_smoother" manual_update = "manual_update" test_run = "test_run" diff --git a/tests/test_units/test_fmuprovider_class.py b/tests/test_units/test_fmuprovider_class.py index b2f1ccab3..fa3545102 100644 --- a/tests/test_units/test_fmuprovider_class.py +++ b/tests/test_units/test_fmuprovider_class.py @@ -411,8 +411,13 @@ def test_fmuprovider_workflow_reference(fmurun_w_casemetadata, globalconfig2): def test_ert_simulation_modes_one_to_one() -> None: """Ensure dataio known modes match those defined by Ert. - These are currently defined in `ert.mode_definitions`. `MODULE_MODE` is skipped due - to seemingly being relevant to Ert internally -- the modes are duplicated there.""" + These are currently defined in `ert.mode_definitions`. + + - `MODULE_MODE` is skipped due to seemingly being relevant to Ert internally. + The modes are duplicated there. + - `iterative_ensemble_mode` was removed in Ert 14. It must be ignored here for as + long as we support Python 3.8. + """ ert_mode_definitions = importlib.import_module("ert.mode_definitions") ert_modes = { getattr(ert_mode_definitions, name) @@ -422,4 +427,10 @@ def test_ert_simulation_modes_one_to_one() -> None: and isinstance(getattr(ert_mode_definitions, name), str) } dataio_known_modes = {mode.value for mode in ErtSimulationMode} + + # TODO: Remove this check when Python 3.8 deprecated. + ert_version = importlib.metadata.version("ert") + if int(ert_version.split(".")[0]) >= 14: + dataio_known_modes.discard("iterative_ensemble_smoother") + assert ert_modes == dataio_known_modes