-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Limit and Skip filters #295
Conversation
The tests inside the
@pytest.mark.parametrize(
"limit_value",
[
pytest.param(10, id="typical"),
pytest.param(0, id="low boundary"),
pytest.param(9999, id="high boundary"),
],
)
@patch.object(Query, "setLimit")
def test_valid_limit_value(self, query_mock, limit_value):
test_filter = SearchAPILimitFilter(limit_value)
test_filter.apply_filter(query_mock)
query_mock.setLimit.assert_called_once_with((0, limit_value))
@pytest.mark.parametrize(
"skip_value", [pytest.param(10, id="typical"), pytest.param(0, id="boundary")],
)
@patch("datagateway_api.src.datagateway_api.icat.filters.get_icat_properties", return_value={"maxEntities":5000})
@patch.object(Query, "setLimit")
def test_valid_skip_value(self, query_mock, get_icat_properties_mock, skip_value):
test_filter = PythonICATSkipFilter(skip_value)
test_filter.apply_filter(query_mock)
limit_value = get_icat_properties_mock()["maxEntities"]
query_mock.setLimit.assert_called_once_with((skip_value, limit_value)) |
Codecov Report
@@ Coverage Diff @@
## master #295 +/- ##
==========================================
+ Coverage 86.23% 86.89% +0.65%
==========================================
Files 37 37
Lines 2667 2670 +3
Branches 216 217 +1
==========================================
+ Hits 2300 2320 +20
+ Misses 341 324 -17
Partials 26 26
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks good, I think it might be benefical to change client_use
to a name more focused on filters.
As for the tests, I think let's keep them as they are now (i.e. lets focus on the search API deadline) and refactor/group the tests when there is time. I think I blur the line between unit and integration tests quite a lot (mainly for speed to write the tests) but this might not be the optimal way to test. I would like this repo to have a set of unit tests which can be run without a working ICAT instance attached to it but I think the higher priority is delivering a solution for the search API. I think the mixture of tests that are in this repo do give good coverage though, and are ultimately better than the small amount of testing that used to be present in this repo. TL;DR - the testing serves its purpose to know we're not breaking stuff, but could do with a refactor to make adhere to 'proper' developer practices.
Sounds good about the tests :) |
Approved because I know you can fix merge conflicts :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that adding a commit will dismiss my review, so maybe second time lucky
This PR will close #262
This PR will close #263
Description
The Limit (
SearchAPILimitFilter
) and Skip (SearchAPISkipFilter
) filters are already implemented. To reduce duplication, they inherit fromPythonICATLimitFilter
andPythonICATSkipFilter
. ThePythonICATSkipFilter
class connects to ICAT to get themaxEntities
value applying the Skip filter to the ICAT query so this PR refactors thePythonICATSkipFilter
class to take aclient_use
value in order to allow for client configuration for both Search API and DataGateway API.It also adds tests which test the
SearchAPILimitFilter
andSearchAPISkipFilter
classes.Testing Instructions
icatdb Generator Script Consistency Test
CI job fails, is this because of a deliberate change made to the script to change generated data (which isn't actually a problem) or is here an underlying issue with the changes made?fix:
,feat:
orBREAKING CHANGE:
so a release is automatically made via GitHub Actions upon merge?Agile Board Tracking
Connect to #262
Connect to #263