Skip to content

Commit

Permalink
Ensure no duplicate keys in SummaryConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Mar 8, 2024
1 parent bd37ca9 commit 006499c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ert/config/summary_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SummaryConfig(ResponseConfig):
def __post_init__(self) -> None:
if isinstance(self.refcase, list):
self.refcase = {datetime.fromisoformat(val) for val in self.refcase}
self.keys = sorted(set(self.keys))
if len(self.keys) < 1:
raise ValueError("SummaryConfig must be given at least one key")

Expand Down
3 changes: 0 additions & 3 deletions tests/integration_tests/test_storage_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ def test_that_storage_matches(tmp_path, source_root, snapshot, monkeypatch):

# We need to normalize some irrelevant details:
experiment.response_configuration["summary"].refcase = {}
experiment.response_configuration["summary"].keys = sorted(
set(experiment.response_configuration["summary"].keys)
)
experiment.parameter_configuration["PORO"].mask_file = ""

snapshot.assert_match(
Expand Down
7 changes: 7 additions & 0 deletions tests/unit_tests/config/test_summary_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ def test_rading_empty_summaries_raises(wopr_summary):
unsmry.to_file("CASE.UNSMRY")
with pytest.raises(ValueError, match="Did not find any summary values"):
SummaryConfig("summary", "CASE", ["WWCT:OP1"], None).read_from_file(".", 0)


def test_summary_config_normalizes_list_of_keys():
assert SummaryConfig("summary", "CASE", ["FOPR", "WOPR", "WOPR"]).keys == [
"FOPR",
"WOPR",
]
2 changes: 1 addition & 1 deletion tests/unit_tests/storage/test_local_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_writing_to_read_only_storage_raises(tmp_path):
input_file=st.text(
alphabet=st.characters(min_codepoint=65, max_codepoint=90)
),
keys=st.lists(summary_keys, max_size=3, min_size=1),
keys=summary_keys,
refcase=st.just(None),
),
),
Expand Down

0 comments on commit 006499c

Please sign in to comment.