Skip to content

Commit

Permalink
Minor tweaks to the validator
Browse files Browse the repository at this point in the history
- Add --version flag for the validator
- Do 'minimal' tests first, as this is where actual model deserialization occurs
  • Loading branch information
ml-evs committed Aug 27, 2021
1 parent 96ceacd commit ad1870b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 7 additions & 0 deletions optimade/validator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" This module contains the ImplementationValidator class and corresponding command line tools. """
# pylint: disable=import-outside-toplevel
from optimade import __version__, __api_version__
from .validator import ImplementationValidator
from .utils import DEFAULT_CONN_TIMEOUT

Expand Down Expand Up @@ -98,6 +99,12 @@ def validate(): # pragma: no cover
help="Additional HTTP headers to use for each request, specified as a JSON object.",
)

parser.add_argument(
"--version",
action="version",
version=f"optimade-validator running from optimade-python-tools v{__version__}, OPTIMADE specification v{__api_version__}.",
)

parser.add_argument(
"--timeout",
type=float,
Expand Down
15 changes: 6 additions & 9 deletions optimade/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,6 @@ def validate_implementation(self):
entry_info_endpoint
)

# Use the _entry_info_by_type to construct filters on the relevant endpoints
if not self.minimal:
for endp in self.available_json_endpoints:
self._log.debug("Testing queries on JSON entry endpoint of %s", endp)
self._recurse_through_endpoint(endp)

# Test that the results from multi-entry-endpoints obey, e.g. page limits,
# and that all entries can be deserialized with the patched models.
# These methods also set the test_ids for each type of entry, which are validated
Expand All @@ -340,6 +334,12 @@ def validate_implementation(self):
self._log.debug("Testing single entry request of type %s", endp)
self._test_single_entry_endpoint(endp)

# Use the _entry_info_by_type to construct filters on the relevant endpoints
if not self.minimal:
for endp in self.available_json_endpoints:
self._log.debug("Testing queries on JSON entry endpoint of %s", endp)
self._recurse_through_endpoint(endp)

# Test that the links endpoint can be serialized correctly
self._log.debug("Testing %s endpoint", CONF.links_endpoint)
self._test_info_or_links_endpoint(CONF.links_endpoint)
Expand Down Expand Up @@ -998,9 +998,6 @@ def _test_multi_entry_endpoint(self, endp: str) -> None:
"""Requests and deserializes a multi-entry endpoint with the
appropriate model.
TODO: deserialization is currently classed as an optional
test until our models are robust to support levels.
Parameters:
request_str: The multi-entry request to make, e.g.,
"structures?filter=nsites<10"
Expand Down

0 comments on commit ad1870b

Please sign in to comment.