Skip to content

Commit

Permalink
#141: Add test case for distinct filter on count endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Apr 12, 2021
1 parent 0322a99 commit 1d63692
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions test/icat/endpoints/test_count_with_filters_icat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@


class TestICATCountWithFilters:
@pytest.mark.usefixtures("single_investigation_test_data")
@pytest.mark.parametrize(
"query_params, expected_result",
[
pytest.param(
'?where={"title": {"like": "Test data for the Python ICAT Backend on'
' on DataGateway API"}}',
5,
id="Filter on test data",
),
pytest.param(
'?where={"title": {"like": "Test data for the Python ICAT Backend on'
' on DataGateway API"}}&distinct=["startDate"]',
1,
id="Distinct test data",
),
],
)
@pytest.mark.usefixtures("multiple_investigation_test_data")
def test_valid_count_with_filters(
self, flask_test_app_icat, valid_icat_credentials_header,
self,
flask_test_app_icat,
valid_icat_credentials_header,
query_params,
expected_result,
):
test_response = flask_test_app_icat.get(
'/investigations/count?where={"title": {"like": "Test data for the Python'
' ICAT Backend on DataGateway API"}}',
f"/investigations/count{query_params}",
headers=valid_icat_credentials_header,
)

assert test_response.json == 1
assert test_response.json == expected_result

def test_valid_no_results_count_with_filters(
self, flask_test_app_icat, valid_icat_credentials_header,
Expand Down

0 comments on commit 1d63692

Please sign in to comment.