Skip to content

Commit

Permalink
Patch validating forward model config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanDeHoop committed Jan 7, 2025
1 parent ef4e3de commit f9fca16
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tests/everest/test_config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from argparse import ArgumentParser
from pathlib import Path
from typing import Any
from unittest.mock import patch

import pytest
from pydantic import ValidationError
Expand Down Expand Up @@ -957,19 +958,21 @@ def test_that_non_existing_workflow_jobs_cause_error():
],
)
def test_warning_forward_model_write_objectives(objective, forward_model, warning_msg):
if warning_msg is not None:
with pytest.warns(ConfigWarning, match=warning_msg):
EverestConfig.with_defaults(
objective_functions=[{"name": o} for o in objective],
forward_model=forward_model,
)
else:
with warnings.catch_warnings():
warnings.simplefilter("error", category=ConfigWarning)
EverestConfig.with_defaults(
objective_functions=[{"name": o} for o in objective],
forward_model=forward_model,
)
# model.realizations is non-empty and therefore this test will run full validation on forward model schema, we don't want that for this test
with patch("everest.config.everest_config.validate_forward_model_configs"):
if warning_msg is not None:
with pytest.warns(ConfigWarning, match=warning_msg):
EverestConfig.with_defaults(
objective_functions=[{"name": o} for o in objective],
forward_model=forward_model,
)
else:
with warnings.catch_warnings():
warnings.simplefilter("error", category=ConfigWarning)
EverestConfig.with_defaults(
objective_functions=[{"name": o} for o in objective],
forward_model=forward_model,
)


def test_deprecated_keyword_report_steps():
Expand Down

0 comments on commit f9fca16

Please sign in to comment.