Skip to content

Commit

Permalink
Tweaked some messages and tidied up
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Sep 21, 2020
1 parent 5685ad7 commit 3c3f3d3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions optimade/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,11 @@ def _recurse_through_endpoint(self, endp: str) -> Tuple[bool, str]:
# check support level of property
prop_type = _impl_properties[prop]["type"]
sortable = _impl_properties[prop]["sortable"]
optional = True
if prop in CONF.entry_schemas[endp]:
optional = (
CONF.entry_schemas[endp].get(prop, {}).get("queryable")
== SupportLevel.OPTIONAL
)
optional = (
prop in CONF.entry_schemas
and CONF.entry_schemas[endp].get(prop, {}).get("queryable")
== SupportLevel.OPTIONAL
)

if optional and not self.run_optional_tests:
continue
Expand Down Expand Up @@ -497,20 +496,23 @@ def _construct_queries_for_property(

if prop_type is None:
raise ResponseError(
f"Cannot validate queries on {prop} as field type was not reported in /info/{endp}"
f"Cannot validate queries on {prop} as field type was not reported in `/info/{endp}`"
)

# this is the case of a provider field
if prop not in CONF.entry_schemas[endp]:
if self.provider_prefix is None:
raise ResponseError(
f"Found unknown field {prop} and no provider prefix was provided in `/info`"
f"Found unknown field '{prop}' in `/info/{endp}` and no provider prefix was provided in `/info`"
)
elif not prop.startswith(f"_{self.provider_prefix}"):
raise ResponseError(
f'Found unknown field {prop} that did not start with provider prefix "_{self.provider_prefix}"'
f"Found unknown field '{prop}' that did not start with provider prefix '_{self.provider_prefix}'"
)
return True, f"Found provider field {prop}, will not test queries."
return (
True,
f"Found provider field '{prop}', will not test queries as they are strictly optional.",
)

query_optional = False
if prop in CONF.entry_schemas[endp]:
Expand Down

0 comments on commit 3c3f3d3

Please sign in to comment.