Skip to content

Commit

Permalink
add error message upon recieving non ga4gh type report
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen2x committed May 17, 2022
1 parent 0ac425f commit f46edae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
15 changes: 9 additions & 6 deletions ga4gh/testbed/submit/report_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ def submit_report(series_id, series_token, report:Report, url="http://localhost:
report - GA4GH report object
url - URL of the testbed server
'''
results = {
"status_code": None,
"error_message": None,
"report_id": None
}

if type(report) != Report:
raise Exception()
results["status_code"] = 400
results["error_message"] = "Report submitted is not a GA4GH Report object"
return results

header = {"GA4GH-TestbedReportSeriesId": series_id, "GA4GH-TestbedReportSeriesToken": series_token}
submit_request = requests.post(url, headers=header ,json=json.loads(report.to_json()))

results = {
"status_code": submit_request.status_code,
"error_message": None,
"report_id": None
}
results["status_code"] = submit_request.status_code

if submit_request.status_code == 200:
results["report_id"] = submit_request.json()["id"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
"http://localhost:4500/reports",
200
),
#(
# "1edb5213-52a2-434f-a7b8-b101fea8fb30",
# "K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn",
# "",
# "http://localhost:4500/reports",
# 400
#),
#(
# "1edb5213-52a2-434f-a7b8-b101fea8fb30",
# "K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn",
# {},
# "http://localhost:4500/reports",
# 500
#),
(
"1edb5213-52a2-434f-a7b8-b101fea8fb30",
"K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn",
"",
"http://localhost:4500/reports",
400
),
(
"1edb5213-52a2-434f-a7b8-b101fea8fb30",
"K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn",
{},
"http://localhost:4500/reports",
400
),
(
"",
"K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn",
Expand Down

0 comments on commit f46edae

Please sign in to comment.