Skip to content

Commit

Permalink
chore: improve error messages for invalid characters in variables nam…
Browse files Browse the repository at this point in the history
…es (#536)

* chore: improve error messages for invalid characters in variables names

ECALC-647
  • Loading branch information
frodehk committed Jun 21, 2024
1 parent 9684fe5 commit 325bfec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/libecalc/presentation/yaml/validation_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
CUSTOM_MESSAGES = {
"missing": "This keyword is missing, it is required",
"extra_forbidden": "This is not a valid keyword",
"string_pattern_mismatch": "The string/name contains illegal characters. Allowed characters are: {pattern}. "
"A good start can be to check the string/name for space, which is not allowed.",
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ def test_invalid_time_series_headers(self, header):
interpolation_type=None,
)
)
assert "String should match pattern '^[A-Za-z][A-Za-z0-9_.,\\-\\s#+:\\/]*$'" in str(ve.value)
assert (
"SIM1:\nDEFAULT.headers[0]:\t"
"The string/name contains illegal characters. "
"Allowed characters are: ^[A-Za-z][A-Za-z0-9_.,\\-\\s#+:\\/]*$"
) in str(ve.value)

@pytest.mark.parametrize(
"header",
Expand Down Expand Up @@ -321,7 +325,11 @@ def test_invalid_resource_names(self, resource_name):
interpolation_type=None,
)
)
assert "String should match pattern '^[A-Za-z][A-Za-z0-9_]*$'" in str(ve.value)
assert (
f"\n{resource_name}:\nDEFAULT.name:\t"
f"The string/name contains illegal characters. "
f"Allowed characters are: ^[A-Za-z][A-Za-z0-9_]*$"
) in str(ve.value)

def test_interpretation_of_interpolation_type_for_default_resource(self):
"""Check default interpolation for DEFAULT time series."""
Expand Down

0 comments on commit 325bfec

Please sign in to comment.