-
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.
#150: Add tests for ICAT skip filters
- Loading branch information
1 parent
7fe62ff
commit 34d46ba
Showing
1 changed file
with
29 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,29 @@ | ||
import pytest | ||
|
||
from datagateway_api.common.config import config | ||
from datagateway_api.common.exceptions import FilterError | ||
from datagateway_api.common.icat.filters import PythonICATSkipFilter | ||
|
||
|
||
class TestICATSkipFilter: | ||
@pytest.mark.parametrize( | ||
"skip_value", [pytest.param(10, id="typical"), pytest.param(0, id="boundary")], | ||
) | ||
def test_valid_skip_value(self, icat_query, skip_value): | ||
test_filter = PythonICATSkipFilter(skip_value) | ||
test_filter.apply_filter(icat_query) | ||
|
||
assert icat_query.limit == ( | ||
skip_value, | ||
config.get_icat_properties()["maxEntities"], | ||
) | ||
|
||
@pytest.mark.parametrize( | ||
"skip_value", | ||
[pytest.param(-375, id="extreme invalid"), pytest.param(-1, id="boundary")], | ||
) | ||
def test_invalid_skip_value(self, icat_query, skip_value): | ||
test_filter = PythonICATSkipFilter(skip_value) | ||
|
||
with pytest.raises(FilterError): | ||
test_filter.apply_filter(icat_query) |