Skip to content

Commit

Permalink
Add --minimal/--page_limit validator options and remove old code (#571)
Browse files Browse the repository at this point in the history
* Added --minimal and --page_limit flags to validator

* Report single entry endpoint as having failed when not tested

* Removed defunct validator data code

* Fixed formatting in help string

* Fix typo in validator function name
  • Loading branch information
ml-evs committed Nov 4, 2020
1 parent 7700324 commit 7e932df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 55 deletions.
13 changes: 13 additions & 0 deletions optimade/validator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ def validate():
help="Whether to exit on first test failure.",
)

parser.add_argument(
"-m", "--minimal", action="store_true", help="Run only a minimal test set."
)

parser.add_argument(
"--page_limit",
type=int,
default=5,
help="Alter the requested page limit for some tests.",
)

args = vars(parser.parse_args())

if os.environ.get("OPTIMADE_VERBOSITY") is not None:
Expand Down Expand Up @@ -108,6 +119,8 @@ def validate():
index=args["index"],
run_optional_tests=not args["skip_optional"],
fail_fast=args["fail_fast"],
minimal=args["minimal"],
page_limit=args["page_limit"],
)

try:
Expand Down
48 changes: 0 additions & 48 deletions optimade/validator/data/__init__.py

This file was deleted.

16 changes: 9 additions & 7 deletions optimade/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__( # pylint: disable=too-many-arguments
fail_fast: bool = False,
as_type: str = None,
index: bool = False,
minimal: bool = False,
):
"""Set up the tests to run, based on constants in this module
for required endpoints.
Expand All @@ -100,6 +101,7 @@ def __init__( # pylint: disable=too-many-arguments
from implementation into, e.g. "structures". Requires `base_url`
to be pointed to the corresponding endpoint.
index: Whether to validate the implementation as an index meta-database.
minimal: Whether or not to run only a minimal test set.
"""
self.verbosity = verbosity
Expand All @@ -109,6 +111,7 @@ def __init__( # pylint: disable=too-many-arguments
self.run_optional_tests = run_optional_tests
self.fail_fast = fail_fast
self.respond_json = respond_json
self.minimal = minimal

if as_type is None:
self.as_type_cls = None
Expand Down Expand Up @@ -287,9 +290,10 @@ def validate_implementation(self):
self._entry_info_by_type[endp] = entry_info.dict()

# Use the _entry_info_by_type to construct filters on the relevant endpoints
for endp in self.available_json_endpoints:
self._log.debug("Testing queries on JSON entry endpoint of %s", endp)
self._recurse_through_endpoint(endp)
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.
Expand Down Expand Up @@ -872,10 +876,8 @@ def _test_multi_entry_endpoint(self, endp: str) -> None:
response, response_cls, request=request_str, optional=True
)

self._get_single_id_from_multi_entry_endpoint(deserialized, request=request_str)
if deserialized:
self._get_single_id_from_mutli_entry_endpoint(
deserialized, request=request_str
)
self._test_data_available_matches_data_returned(deserialized)

@test_case
Expand Down Expand Up @@ -1067,7 +1069,7 @@ def _test_page_limit(
)

@test_case
def _get_single_id_from_mutli_entry_endpoint(self, deserialized):
def _get_single_id_from_multi_entry_endpoint(self, deserialized):
"""Scrape an ID from the multi-entry endpoint to use as query
for single entry endpoint.
Expand Down

0 comments on commit 7e932df

Please sign in to comment.