Skip to content

Commit

Permalink
Merge pull request #685 from NatLibFi/targeted-schemathesis-tests
Browse files Browse the repository at this point in the history
Project-targeted Schemathesis test and OpenAPI schema fix
  • Loading branch information
juhoinkinen authored Mar 23, 2023
2 parents 4bf5610 + 3f25671 commit 38ec228
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
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)

0 comments on commit 38ec228

Please sign in to comment.