Skip to content

Commit

Permalink
#150: Add tests for ICAT skip filters
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 11, 2020
1 parent 7fe62ff commit 34d46ba
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/icat/filters/test_skip_filter.py
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)

0 comments on commit 34d46ba

Please sign in to comment.