Skip to content

Commit

Permalink
Merge 40ed716 into 0dc40d7
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen2x committed Apr 8, 2022
2 parents 0dc40d7 + 40ed716 commit 52f6742
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ jobs:
- name: Install dependencies
run: pip install -r requirements.txt

- name: Run Testbed API
run: docker run -d -p 4500:4500 ga4gh/ga4gh-testbed-api:0.1.0

- name: Service Health Check
uses: jtalk/url-health-check-action@v2
with:
url: http://localhost:4500/reports
follow-redirect: false
max-attempts: 6
retry-delay: 10s
retry-all: true

- name: Run Tests
run: python -m pytest --cov

Expand Down
Empty file.
19 changes: 19 additions & 0 deletions ga4gh/testbed/submit/report_submitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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)
return submit_request.status_code

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,result"
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, result):
submitter = ReportSubmitter
assert submitter.submit_report(series_id, series_token, report, url) == result

0 comments on commit 52f6742

Please sign in to comment.