Skip to content

Commit

Permalink
#150: Add invalid tests for data creation
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 25, 2020
1 parent e358ec7 commit e1f07b7
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions test/icat/test_standard_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,43 @@ def test_invalid_create_data(self):
# Invalid request body
pass

def test_invalid_create_data_1(self):
# TODO - Rename function
# Target ICATObjectExistsError
pass
def test_invalid_create_data(self, flask_test_app, valid_credentials_header):
"""An investigation requires a minimum of: name, visitId, facility, type"""

invalid_request_body = {
"title": "Test Title for DataGateway API Backend testing",
}

test_response = flask_test_app.post(
"/investigations",
headers=valid_credentials_header,
json=invalid_request_body,
)

assert test_response.status_code == 400

def test_invalid_existing_data_create(
self, flask_test_app, valid_credentials_header, single_investigation_test_data,
):
"""This test targets raising ICATObjectExistsError, causing a 400"""

# entity.as_dict() removes details about facility and type, hence they're
# hardcoded here instead of using sinle_investigation_test_data
existing_object_json = {
"name": single_investigation_test_data[0]["name"],
"title": single_investigation_test_data[0]["title"],
"visitId": single_investigation_test_data[0]["visitId"],
"facility": 1,
"type": 1,
}

test_response = flask_test_app.post(
"/investigations",
headers=valid_credentials_header,
json=existing_object_json,
)

assert test_response.status_code == 400

def test_valid_multiple_update_data(
self,
Expand Down

0 comments on commit e1f07b7

Please sign in to comment.