Skip to content

Commit

Permalink
Including suggestions from ISSUE comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckKollar committed Aug 29, 2024
1 parent b9630bb commit 44aa495
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions dev/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ def check_for_valid_application_context() -> None:
Check for a valid auery parameter application_context, and if not found abort with a 400.
"""
application_context = request.args.get('application_context')
if application_context != "HUBMAP":
abort(400, "A query parameter of application_context=HUBMAP must be specified")
if application_context is None or application_context.upper() != "HUBMAP":
abort(Response(json.dumps({"message": "A query parameter of application_context=HUBMAP must be specified"}),
400,
mimetype='application/json'))


@app.route('/', methods=['GET'])
Expand Down
21 changes: 17 additions & 4 deletions dev/test_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,44 @@ ASSAYCLASS_URL=$ASSAYCLASS_URL_LOCAL
curl --request GET \
--url "${ASSAYCLASS_URL}"
echo
echo


# Both endpoints require the application_context=HUBMAP parameter to be included, otherwise return a 400.
echo "Only the last one in the group should succeed..."
curl --request GET \
--url "${ASSAYCLASS_URL}/assayclasses" \
--header "Accept: application/json"
echo

curl --request GET \
--url "${ASSAYCLASS_URL}/assayclasses?application_context=HUBMAP" \
--url "${ASSAYCLASS_URL}/assayclasses?application_context=Wrong" \
--header "Accept: application/json"
echo

curl --request GET \
--url "${ASSAYCLASS_URL}/assayclasses?application_context=HUBMAp" \
--header "Accept: application/json"
echo
echo


echo "Only the last one in the group should succeed..."
curl --request GET \
--url "${ASSAYCLASS_URL}/assayclasses/C200010" \
--header "Accept: application/json"
echo

curl --request GET \
--url "${ASSAYCLASS_URL}/assayclasses/xyzzy?application_context=HUBMAP" \
--url "${ASSAYCLASS_URL}/assayclasses/xyzzy?application_context=NoMap" \
--header "Accept: application/json"
echo

curl --request GET \
--url "${ASSAYCLASS_URL}/assayclasses/xyzzy?application_context=huBMAP" \
--header "Accept: application/json"
echo

curl --request GET \
--url "${ASSAYCLASS_URL}/assayclasses/C200010?application_context=HUBMAP" \
--url "${ASSAYCLASS_URL}/assayclasses/C200010?application_context=HUbmAP" \
--header "Accept: application/json"
echo

0 comments on commit 44aa495

Please sign in to comment.