Skip to content

Commit

Permalink
test: add tests for TestSearchAPILimitFilter #262
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Bozhinov committed Dec 2, 2021
1 parent 2eb14cf commit 7257672
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/search_api/test_limit_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest

from datagateway_api.src.common.exceptions import FilterError
from datagateway_api.src.search_api.filters import SearchAPILimitFilter


class TestSearchAPILimitFilter:
@pytest.mark.parametrize(
"limit_value",
[
pytest.param(10, id="typical"),
pytest.param(0, id="low boundary"),
pytest.param(9999, id="high boundary"),
],
)
def test_valid_limit_value(self, icat_query, limit_value):
test_filter = SearchAPILimitFilter(limit_value)
test_filter.apply_filter(icat_query)

assert icat_query.limit == (0, limit_value)

@pytest.mark.parametrize(
"limit_value",
[pytest.param(-50, id="extreme invalid"), pytest.param(-1, id="boundary")],
)
def test_invalid_limit_value(self, icat_query, limit_value):
with pytest.raises(FilterError):
SearchAPILimitFilter(limit_value)

0 comments on commit 7257672

Please sign in to comment.