Skip to content

Commit

Permalink
#150: Add tests for no result requests
Browse files Browse the repository at this point in the history
- This was trying to cover 404s but I'm not sure how I'd get a count query to 404..
  • Loading branch information
MRichards99 committed Nov 25, 2020
1 parent bead8cf commit a2fd644
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/icat/test_standard_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ def test_valid_get_with_filters(

assert response_json == single_investigation_test_data

def test_valid_no_results_get_with_filters(
self, flask_test_app, valid_credentials_header,
):
test_response = flask_test_app.get(
'/investigations?where={"title": {"eq": "This filter should cause a 404 for'
'testing purposes..."}}',
headers=valid_credentials_header,
)

assert test_response.status_code == 404

@pytest.mark.usefixtures("multiple_investigation_test_data")
def test_valid_get_with_filters_distinct(
self, flask_test_app, valid_credentials_header,
Expand Down Expand Up @@ -199,7 +210,7 @@ def test_invalid_attribute_update(

assert test_response.status_code == 400

def test_valid_get_one_with_filters(
def test_valid_findone_with_filters(
self, flask_test_app, valid_credentials_header, single_investigation_test_data,
):
test_response = flask_test_app.get(
Expand All @@ -211,6 +222,17 @@ def test_valid_get_one_with_filters(

assert response_json == single_investigation_test_data

def test_valid_no_results_findone_with_filters(
self, flask_test_app, valid_credentials_header,
):
test_response = flask_test_app.get(
'/investigations/findone?where={"title": {"eq": "This filter should cause a'
'404 for testing purposes..."}}',
headers=valid_credentials_header,
)

assert test_response.status_code == 404

@pytest.mark.usefixtures("single_investigation_test_data")
def test_valid_count_with_filters(self, flask_test_app, valid_credentials_header):
test_response = flask_test_app.get(
Expand All @@ -221,6 +243,17 @@ def test_valid_count_with_filters(self, flask_test_app, valid_credentials_header

assert test_response.json == 1

def test_valid_no_results_count_with_filters(
self, flask_test_app, valid_credentials_header,
):
test_response = flask_test_app.get(
'/investigations/count?where={"title": {"eq": "This filter should cause a'
'404 for testing purposes..."}}',
headers=valid_credentials_header,
)

assert test_response.json == 0

def test_valid_get_with_id(
self, flask_test_app, valid_credentials_header, single_investigation_test_data,
):
Expand Down

0 comments on commit a2fd644

Please sign in to comment.