Skip to content

Commit

Permalink
Add unit tests for bad requests
Browse files Browse the repository at this point in the history
  • Loading branch information
UnniKohonen authored and osma committed Sep 16, 2024
1 parent 51b307e commit 356c88c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ def test_rest_detect_language_unknown(app):
assert {"language": None, "score": 1} in result["results"]


def test_rest_detect_language_no_text(app):
with app.app_context():
result = annif.rest.detect_language({"text": "", "candidates": ["en"]})
assert {"language": None, "score": 1} in result["results"]


def test_rest_detect_language_no_candidates(app):
with app.app_context():
result = annif.rest.detect_language({"text": "example text", "candidates": []})
assert result.status_code == 400


def test_rest_detect_language_unsupported_candidates(app):
with app.app_context():
result = annif.rest.detect_language(
{"text": "example text", "candidates": ["unk"]}
)
assert result.status_code == 400


def test_rest_suggest_public(app):
# public projects should be accessible via REST
with app.app_context():
Expand Down

0 comments on commit 356c88c

Please sign in to comment.