Skip to content

Commit 260e714

Browse files
committed
Use unique dates for lookup in refcase test
After changing to migrating observation configs for users a corner case was introduced where it may be ambiguous which report step was ment as we round to seconds. This changes the test to only apply to refcases with unique dates. There is still the question of whether it is good enough for the migration to work when the refcase has sufficiently distinct report step times.
1 parent e2c3f68 commit 260e714

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

tests/ert/unit_tests/config/test_observations.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from contextlib import ExitStack as does_not_raise
3-
from datetime import datetime, timedelta
3+
from datetime import date, datetime, timedelta
44
from pathlib import Path
55
from textwrap import dedent
66
from typing import cast
@@ -473,14 +473,29 @@ def test_that_the_date_keyword_sets_the_general_index_by_looking_up_time_map():
473473
assert observations["gen_data"].to_dicts()[0]["report_step"] == restart
474474

475475

476-
@given(summary=summaries(), data=st.data())
476+
@given(data=st.data())
477477
@pytest.mark.integration_test
478478
def test_that_the_date_keyword_sets_the_report_step_by_looking_up_refcase(
479-
tmp_path_factory: pytest.TempPathFactory, summary, data
479+
tmp_path_factory: pytest.TempPathFactory, data
480480
):
481+
start_date, *times = sorted(
482+
data.draw(
483+
st.lists(
484+
st.dates(min_value=date(1969, 1, 1), max_value=date(2100, 1, 1)),
485+
min_size=2,
486+
unique=True,
487+
)
488+
)
489+
)
490+
times = [(t - start_date).total_seconds() / 3600 for t in times]
491+
smspec, unsmry = data.draw(
492+
summaries(
493+
start_date=st.just(datetime.combine(start_date, datetime.min.time())),
494+
time_deltas=st.just(times),
495+
)
496+
)
481497
with pytest.MonkeyPatch.context() as patch:
482498
patch.chdir(tmp_path_factory.mktemp("history_observation_values_are_fetched"))
483-
smspec, unsmry = summary
484499
smspec.to_file("ECLIPSE_CASE.SMSPEC")
485500
unsmry.to_file("ECLIPSE_CASE.UNSMRY")
486501
start_date = smspec.start_date.to_datetime()

0 commit comments

Comments
 (0)