Skip to content

Commit

Permalink
Add meta->schema validation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed May 31, 2022
1 parent 281ca78 commit 79f25e0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions optimade/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ def _test_single_entry_endpoint(self, endp: str) -> None:
if response_fields:
request_str += f"?response_fields={','.join(response_fields)}"
response, _ = self._get_endpoint(request_str)
self._test_meta_schema_reporting(response, request_str, optional=True)

if response:
self._deserialize_response(response, response_cls, request=request_str)

Expand Down Expand Up @@ -1035,6 +1037,7 @@ def _test_multi_entry_endpoint(self, endp: str) -> None:

response, _ = self._get_endpoint(request_str)

self._test_meta_schema_reporting(response, request_str, optional=True)
self._test_page_limit(response)

deserialized, _ = self._deserialize_response(
Expand Down Expand Up @@ -1233,6 +1236,23 @@ def _test_bad_version_returns_553(self) -> None:
"v123123", expected_status_code=expected_status_code, optional=True
)

@test_case
def _test_meta_schema_reporting(
self,
response: requests.models.Response,
request_str: str,
):
"""Tests that the endpoint responds with a `meta->schema`."""
if not response.json().get("meta", {}).get("schema"):
raise ResponseError(
f"Query {request_str} did not report a schema in `meta->schema` field."
)

return (
True,
f"Query {request_str} successfully reported a schema in `meta->schema`.",
)

@test_case
def _test_page_limit(
self,
Expand Down

0 comments on commit 79f25e0

Please sign in to comment.