Skip to content

Commit

Permalink
test: change pytest fixture to SearchAPIQuery #260
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Dec 21, 2021
1 parent 6845659 commit 9937c36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
15 changes: 13 additions & 2 deletions test/search_api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from datagateway_api.src.common.config import Config
from datagateway_api.src.search_api.query import SearchAPIQuery


@pytest.fixture(scope="package")
Expand All @@ -18,5 +19,15 @@ def icat_client():


@pytest.fixture()
def icat_query(icat_client):
return Query(icat_client, "Investigation")
def search_api_query_dataset():
return SearchAPIQuery("Dataset")


@pytest.fixture()
def search_api_query_document():
return SearchAPIQuery("Document")


@pytest.fixture()
def search_api_query_instrument():
return SearchAPIQuery("Instrument")
7 changes: 3 additions & 4 deletions test/search_api/filters/test_search_api_limit_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ class TestSearchAPILimitFilter:
pytest.param(9999, id="high boundary"),
],
)
def test_valid_limit_value(self, limit_value):
def test_valid_limit_value(self, limit_value, search_api_query_document):
test_filter = SearchAPILimitFilter(limit_value)
test_query = SearchAPIQuery("Document")
test_filter.apply_filter(test_query)
test_filter.apply_filter(search_api_query_document)

assert test_query.icat_query.query.limit == (0, limit_value)
assert search_api_query_document.icat_query.query.limit == (0, limit_value)

@pytest.mark.parametrize(
"limit_value",
Expand Down
10 changes: 3 additions & 7 deletions test/search_api/filters/test_search_api_skip_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ class TestSearchAPISkipFilter:
@pytest.mark.parametrize(
"skip_value", [pytest.param(10, id="typical"), pytest.param(0, id="boundary")],
)
# TODO - needs to be changed to `SearchAPIQuery`
def test_valid_skip_value(self, icat_query, skip_value):
def test_valid_skip_value(self, search_api_query_document, skip_value):
test_filter = SearchAPISkipFilter(skip_value)
# TODO - probably could make this a fixture? Might need different ones for each
# entity name entrypoint because you can't have args that aren't other fixtures
test_query = SearchAPIQuery("Document")
test_filter.apply_filter(test_query)
test_filter.apply_filter(search_api_query_document)

assert test_query.icat_query.query.limit == (
assert search_api_query_document.icat_query.query.limit == (
skip_value,
get_icat_properties(
Config.config.search_api.icat_url,
Expand Down

0 comments on commit 9937c36

Please sign in to comment.