Skip to content

Commit

Permalink
Add handling for unknown module
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Mar 14, 2024
1 parent ab5d041 commit 76dcb09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ert/config/analysis_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ def __init__(

var_name = "inversion"
key = var_name.lower()
options[module_name][key] = value
try:
options[module_name][key] = value
except KeyError:
all_errors.append(
ConfigValidationError(
f"Invalid configuration: ANALYSIS_SET_VAR {module_name} {var_name}"
)
)

if errors:
all_errors.append(
Expand Down
4 changes: 4 additions & 0 deletions tests/unit_tests/config/test_analysis_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ def test_misfit_configuration(config, expected):
[["OBSERVATIONS", "SAUTO_SCALE", "OBS_*"]],
pytest.raises(ConfigValidationError, match="Unknown variable"),
),
(
[["NOT_A_THING", "AUTO_SCALE", "OBS_*"]],
pytest.raises(ConfigValidationError, match="ANALYSIS_SET_VAR NOT_A_THING"),
),
],
)
def test_config_wrong_module(config, expectation):
Expand Down

0 comments on commit 76dcb09

Please sign in to comment.