Skip to content

Commit

Permalink
Rewrite date type test
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Dec 5, 2024
1 parent f794fa8 commit 0f60f4a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 129 deletions.
Binary file not shown.

This file was deleted.

93 changes: 0 additions & 93 deletions tests/everest/test_data/snake_oil/everest/model/snake_oil_all.yml

This file was deleted.

1 change: 0 additions & 1 deletion tests/everest/test_data/snake_oil/jobs

This file was deleted.

52 changes: 23 additions & 29 deletions tests/everest/test_everlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from tests.everest.test_config_validation import has_error
from tests.everest.utils import relpath

SNAKE_OIL_CONFIG = relpath("test_data/snake_oil/", "everest/model/snake_oil_all.yml")


@pytest.fixture
def min_config():
Expand Down Expand Up @@ -350,34 +348,30 @@ def test_init_context_controls():
assert len(EverestConfig.lint_config_dict(config)) > 0


def test_date_type():
valid_dates = (
"2000-1-1",
"2010-1-1",
"2018-12-31",
)

invalid_dates = (
"32.01.2000",
"2000-1-32",
"fdsafdas",
"01-01-01",
"...",
None,
{},
"2000-2-30",
@pytest.mark.parametrize(
"date, valid",
[
("2000-1-1", True),
("2010-1-1", True),
("2018-12-31", True),
("32.01.2000", False),
("2000-1-32", False),
("fdsafdas", False),
("01-01-01", False),
("...", False),
(None, False),
("2000-2-30", False),
],
)
def test_date_type(date, valid, min_config):
expectation = (
does_not_raise()
if valid
else pytest.raises(ValidationError, match=f"malformed date: {date}")
)

for date in valid_dates + invalid_dates:
config = yaml_file_to_substituted_config_dict(SNAKE_OIL_CONFIG)
config[ConfigKeys.WELLS][0][ConfigKeys.DRILL_DATE] = date

err = EverestConfig.lint_config_dict(config)
if date in valid_dates:
assert not err
else:
assert len(err) > 0, "%s was wrongly accepted" % date
has_error(err, match=f"malformed date: {date}(.*)")
min_config["wells"] = [{"drill_date": date, "name": "test"}]
with expectation:
EverestConfig(**min_config)


@pytest.mark.fails_on_macos_github_workflow
Expand Down
2 changes: 0 additions & 2 deletions tests/everest/test_res_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
skipif_no_opm,
)

TUTORIAL_CONFIG_DIR = "mocked_test_case"


@pytest.mark.parametrize(
"config, expected",
Expand Down

0 comments on commit 0f60f4a

Please sign in to comment.