Skip to content

Commit

Permalink
Rename test files for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Feb 19, 2025
1 parent 602a0c5 commit cfdde3d
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,5 @@
validation:
- warning_level: low
upper_bound: 2.5
lower_bound: 1
- upper_bound: 5
lower_bound: 1
- variable: Primary Energy|Coal
year: 2010
upper_bound: 5
lower_bound: 1
# default warning_level: error
14 changes: 7 additions & 7 deletions tests/test_validate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def test_DataValidator_from_file():
],
}
],
"file": DATA_VALIDATION_TEST_DIR / "simple_validation.yaml",
"file": DATA_VALIDATION_TEST_DIR / "validation_pass.yaml",
}
)
obs = DataValidator.from_file(DATA_VALIDATION_TEST_DIR / "simple_validation.yaml")
obs = DataValidator.from_file(DATA_VALIDATION_TEST_DIR / "validation_pass.yaml")
assert obs == exp

dsd = DataStructureDefinition(TEST_DATA_DIR / "validation" / "definitions")
Expand All @@ -46,7 +46,7 @@ def test_DataValidator_from_file():
)
def test_DataValidator_illegal_structure(name, match):
with pytest.raises(ValueError, match=match):
DataValidator.from_file(DATA_VALIDATION_TEST_DIR / f"validate_{name}.yaml")
DataValidator.from_file(DATA_VALIDATION_TEST_DIR / f"error_{name}.yaml")


@pytest.mark.parametrize(
Expand All @@ -63,7 +63,7 @@ def test_DataValidator_validate_with_definition_raises(dimension, match):
# TODO Undefined unit

data_validator = DataValidator.from_file(
DATA_VALIDATION_TEST_DIR / f"validate_unknown_{dimension}.yaml"
DATA_VALIDATION_TEST_DIR / f"error_unknown_{dimension}.yaml"
)

# validating against a DataStructure with all dimensions raises
Expand All @@ -81,7 +81,7 @@ def test_DataValidator_validate_with_definition_raises(dimension, match):

def test_DataValidator_apply_no_matching_data(simple_df):
data_validator = DataValidator.from_file(
DATA_VALIDATION_TEST_DIR / "simple_validation.yaml"
DATA_VALIDATION_TEST_DIR / "validation_pass.yaml"
)
# no data matches validation criteria, `apply()` passes and returns unchanged object
assert data_validator.apply(simple_df) == simple_df
Expand All @@ -105,7 +105,7 @@ def test_DataValidator_apply_no_matching_data(simple_df):
],
)
def test_DataValidator_apply_fails(simple_df, file, item_1, item_2, item_3, caplog):
data_file = DATA_VALIDATION_TEST_DIR / f"validate_data_fails_{file}.yaml"
data_file = DATA_VALIDATION_TEST_DIR / f"validation_fails_{file}.yaml"
data_validator = DataValidator.from_file(data_file)

failed_validation_message = (
Expand Down Expand Up @@ -191,5 +191,5 @@ def test_DataValidator_warning_order_fail():
match = "Validation criteria for .* not sorted in descending order of severity."
with pytest.raises(ValueError, match=match):
DataValidator.from_file(
DATA_VALIDATION_TEST_DIR / "validate_warning_joined_asc.yaml"
DATA_VALIDATION_TEST_DIR / "error_warning_level_asc.yaml"
)

0 comments on commit cfdde3d

Please sign in to comment.