Skip to content

Commit

Permalink
TST: Add ert hook implementation tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mferrera committed Feb 20, 2024
1 parent 1082ad0 commit 5e565b1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Documentation = "https://fmu-dataio.readthedocs.io"
[project.optional-dependencies]
dev = [
"coverage>=4.1",
"ert",
"hypothesis",
"mypy",
"pydocstyle",
Expand Down
53 changes: 53 additions & 0 deletions tests/test_integration/test_hook_implementations.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 5e565b1

Please sign in to comment.