-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from ga4gh/release/0.2.0
Release/0.2.0 into main
- Loading branch information
Showing
6 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from re import sub | ||
import requests | ||
|
||
|
||
class ReportSubmitter(): | ||
|
||
def submit_report(series_id, series_token, report, url="http://localhost:4500/reports"): | ||
''' | ||
Submits a report to the GA4GH testbed api. | ||
Required arguments: | ||
series_id - A series ID is needed by server to group the report | ||
series_token - A token is needed to verify authenticity | ||
report - GA4GH report in JSON format | ||
url - URL of the testbed server | ||
''' | ||
header = {"GA4GH-TestbedReportSeriesId": series_id, "GA4GH-TestbedReportSeriesToken": series_token} | ||
submit_request = requests.post(url, headers=header ,json=report) | ||
|
||
results = { | ||
"status_code": submit_request.status_code, | ||
"error_message": None, | ||
"report_id": None | ||
} | ||
|
||
if submit_request.status_code == 200: | ||
results["report_id"] = submit_request.json()["id"] | ||
else: | ||
if "message" in submit_request.json().keys(): | ||
results["error_message"] = submit_request.json()["message"] | ||
|
||
return results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import setuptools | ||
|
||
NAME = "ga4gh-testbed-lib" | ||
VERSION = "0.1.2" | ||
VERSION = "0.2.0" | ||
AUTHOR = "Jeremy Adams" | ||
EMAIL = "[email protected]" | ||
|
||
|
56 changes: 56 additions & 0 deletions
56
tests/test_unit/test_ga4gh/test_testbed/test_submit/test_report_submitter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pytest | ||
from ga4gh.testbed.submit.report_submitter import ReportSubmitter | ||
|
||
sample_report = {"schema_name":"ga4gh-testbed-report","schema_version":"0.1.0","testbed_name":"refget-compliance-suite","testbed_version":"","testbed_description":"","platform_name":"","platform_description":"","input_parameters":{},"start_time":"2022-03-22T17:45:37Z","end_time":"2022-03-22T17:46:32Z","status":"PASS","summary":{"unknown":0,"passed":49,"warned":0,"failed":0,"skipped":20},"phases":[]} | ||
|
||
submit_report_inputs = "series_id,series_token,report,url,status_code" | ||
submit_report_cases = [ | ||
( | ||
"1edb5213-52a2-434f-a7b8-b101fea8fb30", | ||
"K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn", | ||
sample_report, | ||
"http://localhost:4500/reports", | ||
200 | ||
), | ||
( | ||
"483382e9-f92b-466d-9427-154d56a75fcf", | ||
"l0HiRbbpjVDKc6k3tQ2skzROB1oAP2IV", | ||
sample_report, | ||
"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 | ||
), | ||
( | ||
"", | ||
"K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn", | ||
sample_report, | ||
"http://localhost:4500/reports", | ||
404 | ||
), | ||
( | ||
"1edb5213-52a2-434f-a7b8-b101fea8fb30", | ||
"", | ||
sample_report, | ||
"http://localhost:4500/reports", | ||
401 | ||
), | ||
] | ||
|
||
@pytest.mark.parametrize(submit_report_inputs, submit_report_cases) | ||
def test_case_submit_report(series_id,series_token,report,url, status_code): | ||
submitter = ReportSubmitter | ||
assert submitter.submit_report(series_id, series_token, report, url)["status_code"] == status_code | ||
|