From ad1870be1db867b8f525f181c1100cee89f5ecb2 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Fri, 27 Aug 2021 14:42:18 +0100 Subject: [PATCH] Minor tweaks to the validator - Add --version flag for the validator - Do 'minimal' tests first, as this is where actual model deserialization occurs --- optimade/validator/__init__.py | 7 +++++++ optimade/validator/validator.py | 15 ++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/optimade/validator/__init__.py b/optimade/validator/__init__.py index 2ef9a8866c..0c4e0be9be 100644 --- a/optimade/validator/__init__.py +++ b/optimade/validator/__init__.py @@ -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 @@ -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, diff --git a/optimade/validator/validator.py b/optimade/validator/validator.py index 00d2403d33..411d500400 100644 --- a/optimade/validator/validator.py +++ b/optimade/validator/validator.py @@ -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 @@ -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) @@ -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"