-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for
TestSearchAPILimitFilter
#262
- Loading branch information
Viktor Bozhinov
committed
Dec 2, 2021
1 parent
2eb14cf
commit 7257672
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |