You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check /get_normalized_nodes, /version and /status responses against the OpenAPI schemas without an Elasticsearch host #51
tests/test_openapi.py (added in #42) holds the hand-written OpenAPI document to the handlers in both directions for paths, methods, query parameters and POST body fields, but it only checks some response bodies against their documented schemas. Those checks mount a handler with a fake or unreachable Elasticsearch client and run jsonschema.validate() on the answer, so they need no Elasticsearch host. They cover /get_allowed_conflations, /get_semantic_types, /status with Elasticsearch down, and /get_setid's error cases (and, in #48, its POST success case with generate_setid() mocked).
Not checked against the document by any test that runs without the su10 host:
/get_normalized_nodes 200 (GET and POST), schema NormalizedNodes. This is the main endpoint. tests/test_normalized_nodes.py covers it, but needs su10 and compares against expected JSON rather than the schema, so a field added to or dropped from the response (or a changed type) fails nothing in a host-free run.
/version 200.
/status 200 when Elasticsearch is up.
Suggested approach
tests/test_normalized_nodes_lookup.py already has a FakeAsyncElasticsearch that answers msearch with canned batches. A test in tests/test_openapi.py could mount NormalizedNodesHandler with it, request a CURIE with and without conflate, description and individual_types, and validate the body against #/components/schemas/NormalizedNodes. That needs $refs resolved, e.g. by validating against a schema that carries the document's components, or with a referencing registry. /version and /status need only small fakes.
Ideally the canned Elasticsearch documents would be copied from a real index, so the test fails if the document drifts from what Babel actually loads, not just from what the fake returns.
/status already validates its error response this way:
Activity