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 committed Jan 19, 2023
1 parent 727236c commit 34c2538
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 @@ -62,6 +62,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 34c2538

Please sign in to comment.