Skip to content

Commit

Permalink
♻️ Participant - update error msgs to standard
Browse files Browse the repository at this point in the history
  • Loading branch information
znatty22 committed Mar 12, 2018
1 parent 853bd9c commit 04999c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions dataservice/api/participant/resources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pprint import pprint
from flask import abort, request
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.orm import joinedload
Expand Down Expand Up @@ -87,7 +86,7 @@ def get(self, kf_id):
participant = Participant.query.filter_by(kf_id=kf_id).one()
except NoResultFound:
abort(404, 'could not find {} `{}`'
.format('Participant', kf_id))
.format('participant', kf_id))
return ParticipantSchema().jsonify(participant)

def patch(self, kf_id):
Expand All @@ -106,7 +105,7 @@ def patch(self, kf_id):
p = Participant.query.filter_by(kf_id=kf_id).one()
except NoResultFound:
abort(404, 'could not find {} `{}`'
.format('Participant', kf_id))
.format('participant', kf_id))

# Partial update - validate but allow missing required fields
try:
Expand Down Expand Up @@ -136,7 +135,7 @@ def delete(self, kf_id):
try:
p = Participant.query.filter_by(kf_id=kf_id).one()
except NoResultFound:
abort(404, 'could not find {} `{}`'.format('Participant', kf_id))
abort(404, 'could not find {} `{}`'.format('participant', kf_id))

db.session.delete(p)
db.session.commit()
Expand Down
1 change: 0 additions & 1 deletion tests/participant/test_participant_resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from pprint import pprint
from datetime import datetime
from dateutil import parser, tz

Expand Down
6 changes: 3 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def test_status_codes(self, client, endpoint, method, status_code):
('/demographics/123', 'PATCH', 'could not find demographic `123`'),
('/demographics/123', 'DELETE', 'could not find demographic `123`'),
('/participants', 'GET', 'success'),
('/participants/123', 'GET', 'could not find Participant `123`'),
('/participants/123', 'PATCH', 'could not find Participant `123`'),
('/participants/123', 'DELETE', 'could not find Participant `123`')
('/participants/123', 'GET', 'could not find participant `123`'),
('/participants/123', 'PATCH', 'could not find participant `123`'),
('/participants/123', 'DELETE', 'could not find participant `123`')
])
def test_status_messages(self, client, endpoint, method, status_message):
"""
Expand Down

0 comments on commit 04999c0

Please sign in to comment.