Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes for the validator #610

Merged
merged 2 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion optimade/validator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def add_failure(
"optional": (print, print),
}
pprint, warning_pprint = pprint_types.get(
"failure_type", (print_failure, print_warning)
failure_type, (print_failure, print_warning)
)

symbol = "!" if failure_type == "internal" else "✖"
Expand Down
19 changes: 10 additions & 9 deletions optimade/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def print_summary(self):
print(
"There were internal validator failures associated with this run.\n"
"If this problem persists, please report it at:\n"
"https://github.com/Materials-Consortia/optimade-python-tools/issues/new.\n"
"https://github.com/Materials-Consortia/optimade-python-tools/issues/new\n"
)

for message in self.results.internal_failure_messages:
Expand Down Expand Up @@ -481,17 +481,16 @@ def _check_response_fields(self, endp: str, fields: List[str]) -> Tuple[bool, st
returned_fields -= CONF.top_level_non_attribute_fields

if expected_fields != returned_fields:
raise RuntimeError(
f"Response fields not obeyed by {endp!r}:\n{expected_fields}\n{returned_fields}"
raise ResponseError(
f"Response fields not obeyed by {endp!r}:\nExpected: {expected_fields}\nReturned: {returned_fields}"
)

return True, "Successfully limited response fields"

else:
return (
None,
f"Unable to test adherence to response fields as no entries were returned for endpoint {endp!r}.",
)
return (
None,
f"Unable to test adherence to response fields as no entries were returned for endpoint {endp!r}.",
)

@test_case
def _construct_queries_for_property(
Expand Down Expand Up @@ -997,7 +996,9 @@ def _test_bad_version_returns_553(self) -> None:
if re.match(VERSIONS_REGEXP, self.base_url_parsed.path) is not None:
expected_status_code = [404, 400]

self._get_endpoint("v123123", expected_status_code=expected_status_code)
self._get_endpoint(
"v123123", expected_status_code=expected_status_code, optional=True
)

@test_case
def _test_page_limit(
Expand Down