Skip to content

Commit

Permalink
#150: Add more invalid tests for update endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 25, 2020
1 parent ba62e44 commit bead8cf
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions test/icat/test_standard_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,50 @@ def test_valid_boundary_update_data(

assert response_json == single_investigation_test_data

def test_invalid_update_data(
def test_invalid_missing_update_data(
self, flask_test_app, valid_credentials_header, single_investigation_test_data,
):
"""There should be an ID in the request body to know which entity to update"""

expected_doi = "Test Data Identifier"
expected_summary = "Test Summary"

update_data_json = {
"doi": expected_doi,
"summary": expected_summary,
"doi": "Test Data Identifier",
"summary": "Test Summary",
}
single_investigation_test_data[0]["doi"] = expected_doi
single_investigation_test_data[0]["summary"] = expected_summary

test_response = flask_test_app.patch(
"/investigations", headers=valid_credentials_header, json=update_data_json,
)

assert test_response.status_code == 400

@pytest.mark.parametrize(
"update_key, update_value",
[
pytest.param("invalidAttr", "Some Value", id="invalid attribute"),
pytest.param("modId", "simple/root", id="meta attribute update"),
],
)
def test_invalid_attribute_update(
self,
flask_test_app,
valid_credentials_header,
single_investigation_test_data,
update_key,
update_value,
):
invalid_update_data_json = {
"id": single_investigation_test_data[0]["id"],
update_key: update_value,
}

test_response = flask_test_app.patch(
"/investigations",
headers=valid_credentials_header,
json=invalid_update_data_json,
)

assert test_response.status_code == 400

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

0 comments on commit bead8cf

Please sign in to comment.