Skip to content

Commit

Permalink
test_update_vallid encounters a datetime faillure
Browse files Browse the repository at this point in the history
  • Loading branch information
Reillyhewitson committed Nov 3, 2022
1 parent b31d037 commit 0e7fc3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion datagateway_api/src/datagateway_api/database/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def commit_changes(self):
except Exception as e:
log.error("Error whilst committing changes to %s, rolling back", self.table)
self.session.rollback()
raise e
raise BadRequestError(f"Bad request: {e}")


class CountQuery(Query):
Expand Down
15 changes: 11 additions & 4 deletions test/datagateway_api/db/endpoints/test_update_by_id_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_valid_update_with_id(
update_data_json = {
"doi": "DB Test Data Identifier",
"summary": "DB Test Summary",
"startDate": "2019-01-04 01:01:01+00:00",
"startDate": "2019-01-04 01:01:01",
}

single_investigation_test_data = single_investigation_test_data_db.to_dict()
Expand All @@ -23,8 +23,15 @@ def test_valid_update_with_id(
headers=valid_db_credentials_header,
json=update_data_json,
)
print(test_response.status_code)
assert test_response.json == single_investigation_test_data

response_json = test_response.json

print(response_json["endDate"])
# The DB returns times with timezone indicators, but does not accept them being created.
# This strips the timezone indicators out so that the results can be compared.
response_json["startDate"] = response_json["startDate"][:-6]

assert response_json == single_investigation_test_data

def test_invalid_update_with_id(
self,
Expand All @@ -47,4 +54,4 @@ def test_invalid_update_with_id(
json=invalid_update_json,
)

assert test_response.json["doi"] == "_" * 255
assert test_response.status_code == 400

0 comments on commit 0e7fc3d

Please sign in to comment.