Skip to content

Commit

Permalink
Add test for installation of everest_models jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
verveerpj committed Oct 31, 2024
1 parent 70e85a7 commit e0178d9
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tests/everest/test_fm_plugins.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import logging
from importlib import resources
from itertools import chain
from typing import Callable, Iterator, Sequence, Type

import pluggy
import pytest
from pydantic import BaseModel

from ert import ForwardModelStepPlugin
from everest.config import EverestConfig
from everest.plugins import hook_impl, hook_specs, hookimpl
from everest.simulator.everest_to_ert import everest_to_ert_config
from everest.strings import EVEREST
from everest.util.forward_models import collect_forward_models

SNAKE_CONFIG_PATH = "test_data/snake_oil/everest/model/snake_oil.yml"


class MockPluginManager(pluggy.PluginManager):
"""A testing plugin manager"""
Expand Down Expand Up @@ -43,11 +49,14 @@ def test_jobs():

def test_everest_models_jobs(plugin_manager):
pytest.importorskip("everest_models")
pm = plugin_manager()
assert any(
hook.plugin_name.startswith(EVEREST)
for hook in pm.hook.get_forward_models.get_hookimpls()
)
ert_config = everest_to_ert_config(EverestConfig.load_file(SNAKE_CONFIG_PATH))
jobs = list(resources.contents("everest_models.jobs"))
assert bool(jobs)
for job in jobs:
if job.startswith("fm_"):
job_class = ert_config.installed_forward_model_steps.get(job.lstrip("fm_"))
assert job_class is not None
assert isinstance(job_class, ForwardModelStepPlugin)


def test_multiple_plugins(plugin_manager):
Expand Down

0 comments on commit e0178d9

Please sign in to comment.