From 5e565b173bd4d3b5f29cd1872a8407da98749eff Mon Sep 17 00:00:00 2001 From: mferrera Date: Tue, 20 Feb 2024 13:59:24 +0100 Subject: [PATCH] TST: Add ert hook implementation tests This tests that the forward models provided to fmu-dataio (currently none) and the workflows (just the one) are registered in ert as expected, i.e., that they are valid to ert. --- pyproject.toml | 1 + .../test_hook_implementations.py | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/test_integration/test_hook_implementations.py diff --git a/pyproject.toml b/pyproject.toml index 2d02a161f..7846ff0ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ Documentation = "https://fmu-dataio.readthedocs.io" [project.optional-dependencies] dev = [ "coverage>=4.1", + "ert", "hypothesis", "mypy", "pydocstyle", diff --git a/tests/test_integration/test_hook_implementations.py b/tests/test_integration/test_hook_implementations.py new file mode 100644 index 000000000..88822c1e9 --- /dev/null +++ b/tests/test_integration/test_hook_implementations.py @@ -0,0 +1,53 @@ +import fmu.dataio.hook_implementations.jobs +from ert.shared.plugins.plugin_manager import ErtPluginManager +from fmu.dataio.scripts import create_case_metadata + + +def test_hook_implementations(): + plugin_manager = ErtPluginManager( + plugins=[ + fmu.dataio.hook_implementations.jobs, + create_case_metadata, + ] + ) + + installable_fms = plugin_manager.get_installable_jobs() + expected_forward_models = {} + for fm_name, fm_location in expected_forward_models.items(): + assert fm_name in installable_fms + assert installable_fms[fm_name].endswith(fm_location) + + assert set(installable_fms) == set(expected_forward_models) + + expected_workflow_jobs = {"WF_CREATE_CASE_METADATA"} + installable_workflow_jobs = plugin_manager.get_installable_workflow_jobs() + for wf_name, wf_location in installable_workflow_jobs.items(): + assert wf_name in expected_workflow_jobs + assert installable_workflow_jobs[wf_name].endswith(wf_location) + + assert set(installable_workflow_jobs) == set(expected_workflow_jobs) + + +def test_hook_implementations_docs(): + plugin_manager = ErtPluginManager( + plugins=[ + fmu.dataio.hook_implementations.jobs, + create_case_metadata, + ] + ) + + installable_fms = plugin_manager.get_installable_jobs() + fm_docs = plugin_manager.get_documentation_for_jobs() + assert set(fm_docs) == set(installable_fms) + for fm_name in installable_fms: + assert fm_docs[fm_name]["description"] != "" + assert fm_docs[fm_name]["examples"] != "" + assert fm_docs[fm_name]["category"] != "other" + + installable_workflow_jobs = plugin_manager.get_installable_workflow_jobs() + wf_docs = plugin_manager.get_documentation_for_workflows() + assert set(wf_docs) == set(installable_workflow_jobs) + for wf_name in installable_fms: + assert wf_docs[wf_name]["description"] != "" + assert wf_docs[wf_name]["examples"] != "" + assert wf_docs[wf_name]["category"] != "other"