Project-targeted Schemathesis test and OpenAPI schema fix #685
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR #682 introduced Schemathesis for testing REST API. However, as noted in #664 (comment), Schemathesis creates random path (and query) parameters, which means most of the test requests target non-existent projects giving just 404 error.
This PR adds a test that targets the methods in the endpoint
/v1/projects/{project_id}*
and uses a fixed project-iddummy-fi
. A project with this id exists, so the test requests probe the actions that are (mostly) missed otherwise.This test noted two attributes in the OpenAPI specification that should be required or nullable, which are fixed. openapi-diff tool tool complains that the fixes break backward compatibility:
However I think the fixes should be harmless for backward compatibility and should be done:
notation
in SuggestionResult should benullable
because it isNone
if the vocabulary does not contain notations, which usually is the caseuri
in subjects of IndexedDocument should be required because otherwise Internal error due toKeyError: 'uri'
occursAt first I thought that also
text
andsubjects
in IndexedDocument should be required, but maybe not, at least that case is covered with an if condition:Annif/annif/rest.py
Line 116 in 4bf5610
Also, this test is quite slow (10-15 s) and when the
suggest-batch
endpoint will be added it becomes even slower (20-25 s), so I marked it "slow" with a pytest decorator and configured pytest to skip it by default. It can be run using-m slow
option: