Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename /validate to /apitest #126

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## [unreleased]
### Added
- An endpoint `/apitest-status` that returns a response containing a link to the eventual json file with the submissions data errors
### Changed
- Renamed `/validate` endpoint to `/apitest`

## [2.5.2]
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Transforms csv submission files (Variant.csv and CaseData.csv) into a json submi

Proxy endpoint to the ClinVar submissions API (dry-run): https://submit.ncbi.nlm.nih.gov/api/v1/submissions/?dry-run=true. Requires a valid API key and a json file containing a submission object. If the request is valid (and the json submission object is validated) returns a response with code 200 and json body with the message value "success".

### validate
### apitest

Proxy endpoint to the ClinVar validate API endpoint: "https://submit.ncbi.nlm.nih.gov/apitest/v1/submissions". Requires a valid API key and a json file containing a submission object. If the json submission document is valid returns a submission ID which can be used for a real submission. If the json submission document is not validated, the endpoint returns a list of errors which will help fixing the document.
Proxy endpoint to the validation API endpoint: (apitest) "https://submit.ncbi.nlm.nih.gov/apitest/v1/submissions". Requires a valid API key and a json file containing a submission object. If the json submission document is valid returns a submission ID which can be used for a real submission. If the json submission document is not validated, the endpoint returns a list of errors which will help fixing the document.

## Running the application using Docker-compose
An example containing a demo setup for the app is included in the docker-compose file. Start the docker-compose demo using this command:
Expand Down
4 changes: 2 additions & 2 deletions preClinVar/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ async def apitest_status(api_key: str = Form(), submission_id: str = Form()) ->
)


@app.post("/validate")
async def validate(api_key: str = Form(), json_file: UploadFile = File(...)):
@app.post("/apitest")
async def apitest(api_key: str = Form(), json_file: UploadFile = File(...)):
"""A proxy to the apitest ClinVar API endpoint"""
# Create a submission header
header = build_header(api_key)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ def test_dry_run():


@responses.activate
def test_validate_wrong_api_key():
"""Test the validate API proxy endpoint without a valid ClinVar API key"""
def test_apitest_wrong_api_key():
"""Test the apitest API proxy endpoint without a valid ClinVar API key"""

# GIVEN a json submission file
json_file = {"json_file": open(subm_json_path, "rb")}
Expand All @@ -304,16 +304,16 @@ def test_validate_wrong_api_key():
status=401, # The ClinVar API returs code 201 when request is successful (created)
)

response = client.post("/validate", data={"api_key": DEMO_API_KEY}, files=json_file)
response = client.post("/apitest", data={"api_key": DEMO_API_KEY}, files=json_file)

# THEN the ClinVar API should return "unauthorized"
assert response.status_code == 401 # Not authorized
assert response.json()["message"] == "No valid API key provided"


@responses.activate
def test_validate():
"""Test the endpoint validate, a proxy to ClinVar apitest, with a mocked ClinVar API response."""
def test_apitest():
"""Tests the endpoint apitest, a proxy to ClinVar apitest, with a mocked ClinVar API response."""

# GIVEN a json submission file
json_file = {"json_file": open(subm_json_path, "rb")}
Expand All @@ -326,7 +326,7 @@ def test_validate():
status=201, # The ClinVar API returs code 201 when request is successful (created)
)

response = client.post("/validate", data={"api_key": DEMO_API_KEY}, files=json_file)
response = client.post("/apitest", data={"api_key": DEMO_API_KEY}, files=json_file)

# THEN the ClinVar API proxy should return "success"
assert response.status_code == 201 # Created
Expand Down
Loading