Skip to content

Commit

Permalink
#150: Add update test
Browse files Browse the repository at this point in the history
- Added some logging to the API to make logging a bit better
  • Loading branch information
MRichards99 committed Nov 24, 2020
1 parent 833f8e9 commit 9e0c56b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions datagateway_api/common/icat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def update_attributes(old_entity, new_entity):
- typically if Python ICAT doesn't allow an attribute to be edited (e.g. modId &
modTime)
"""
log.debug("Updating entity attributes: %s", list(new_entity.keys()))
for key in new_entity:
try:
original_data_attribute = getattr(old_entity, key)
Expand Down
22 changes: 20 additions & 2 deletions test/icat/test_standard_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,26 @@ def test_invalid_delete_with_id(self):
# like invalid get, but try to delete
pass

def test_valid_update_with_id(self):
pass
def test_valid_update_with_id(
self, flask_test_app, valid_credentials_header, single_investigation_test_data,
):
expected_doi = "Test Data Identifier"
expected_summary = "Test Summary"

update_data_json = {
"id": single_investigation_test_data[0]["id"],
"doi": expected_doi,
"summary": expected_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,
)
response_json = prepare_icat_data_for_assertion(test_response.json)

assert response_json == single_investigation_test_data

def test_invalid_update_with_id(self):
pass

0 comments on commit 9e0c56b

Please sign in to comment.