Skip to content

Commit

Permalink
test: add test for /files/count with non-existent dataset pid #327
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 15, 2022
1 parent 2130f0b commit 8e0cfc1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/search_api/endpoints/test_count_dataset_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class TestSearchAPICountDatasetFilesEndpoint:
{"count": 0},
id="Count dataset files with filter to return zero count",
),
pytest.param(
"unknown pid", "{}", {"count": 0}, id="Non-existent dataset pid",
),
],
)
def test_valid_count_dataset_files_endpoint(
Expand All @@ -54,22 +51,24 @@ def test_valid_count_dataset_files_endpoint(
assert test_response.json == expected_json

@pytest.mark.parametrize(
"pid, request_filter",
"pid, request_filter, expected_status_code",
[
pytest.param("0-8401-1070-7", '{"bad filter"}', id="Bad filter"),
pytest.param("0-8401-1070-7", '{"bad filter"}', 400, id="Bad filter"),
pytest.param(
"0-8401-1070-7",
'{"where": {"name": "FILE 4"}}',
400,
id="Where filter inside where query param",
),
pytest.param("my 404 test pid", "{}", 404, id="Non-existent dataset pid"),
],
)
def test_invalid_count_dataset_files_endpoint(
self, flask_test_app_search_api, pid, request_filter,
self, flask_test_app_search_api, pid, request_filter, expected_status_code,
):
test_response = flask_test_app_search_api.get(
f"{Config.config.search_api.extension}/datasets/{pid}/files/count"
f"?where={request_filter}",
)

assert test_response.status_code == 400
assert test_response.status_code == expected_status_code

0 comments on commit 8e0cfc1

Please sign in to comment.