Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project-targeted Schemathesis test and OpenAPI schema fix #685

Merged
merged 5 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ jobs:
- name: Test with pytest
run: |
poetry run pytest --cov=./ --cov-report xml
if [[ ${{ matrix.python-version }} == '3.9' ]]; then
poetry run pytest --cov=./ --cov-report xml --cov-append -m slow
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- name: Save cache
Expand Down
3 changes: 3 additions & 0 deletions annif/openapi/annif.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ components:
notation:
type: string
example: "42.42"
nullable: true
score:
type: number
example: 0.85
Expand All @@ -246,6 +247,8 @@ components:
type: array
items:
type: object
required:
- uri
properties:
uri:
type: string
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ build-backend = "poetry.core.masonry.api"
profile = "black"
line_length = "88"
skip_gitignore = true

[tool.pytest.ini_options]
addopts = "-m 'not slow'"
10 changes: 10 additions & 0 deletions tests/test_openapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Annif REST API / Swagger spec"""
import pytest
import schemathesis
from hypothesis import settings

Expand All @@ -15,3 +16,12 @@ def check_cors(response, case):
def test_api(case, app):
response = case.call_wsgi(app)
case.validate_response(response, additional_checks=(check_cors,))


@pytest.mark.slow
@schema.parametrize(endpoint="/v1/projects/{project_id}")
@settings(max_examples=50)
def test_api_target_dummy_fi(case, app):
case.path_parameters = {"project_id": "dummy-fi"}
response = case.call_wsgi(app)
case.validate_response(response)