Skip to content

Commit

Permalink
feat: validate_schema for int parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
tklockau committed Nov 25, 2024
1 parent bdddbc1 commit 17795a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def _make_errors_readable(errors: ValidationError) -> list[str]:
readable_errors.append(_convert_literal_error_to_string(error))
elif error["type"] in ["bool_type", "bool_parsing"]:
readable_errors.append(_convert_false_type_error_to_string(error, "bool"))
elif error["type"] in ["int_type", "int_parsing"]:
readable_errors.append(_convert_false_type_error_to_string(error, "int"))
else:
raise ValueError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,15 @@ def test_wrong_type_bool():
assert "NOT A BOOLEAN" in actual[0]


def test_wrong_type_int():
data = {"openlabel": {"metadata": {"schema_version": "1.0.0"}, "frames": {"NOT AN INT": {}}}}

actual = validate_schema(data)
assert len(actual) == 1
assert "$.openlabel.frames" in actual[0]
assert "int" in actual[0]
assert "NOT AN INT" in actual[0]


if __name__ == "__main__":
pytest.main([__file__, "-v"])

0 comments on commit 17795a4

Please sign in to comment.