Skip to content

Commit

Permalink
Add a test for the /deöete endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiara Rasi committed Nov 21, 2024
1 parent 3e91bd0 commit 1c7c2af
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

## [unreleased]
### Added
- Delete submission endpoint, with json example (under demo files)
- Delete submission endpoint, with json example (under demo files) and test
### Changed
- Updated API submission schema to the latest available on `ncbi/clinvar` GitHub pages
- Modified the json submission example to use one from the ClinVar GitHib repo (`sample_clinical_significance_hgvs_submission.json`)
Expand Down
8 changes: 2 additions & 6 deletions preClinVar/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@

from preClinVar.__version__ import VERSION
from preClinVar.build import build_header, build_submission
from preClinVar.constants import (
DRY_RUN_SUBMISSION_URL,
SUBMISSION_URL,
VALIDATE_SUBMISSION_URL,
)
from preClinVar.constants import DRY_RUN_SUBMISSION_URL, SUBMISSION_URL, VALIDATE_SUBMISSION_URL
from preClinVar.file_parser import csv_lines, file_fields_to_submission, tsv_lines
from preClinVar.validate import validate_submission

Expand Down Expand Up @@ -241,7 +237,7 @@ async def status(api_key: str = Form(), submission_id: str = Form()) -> JSONResp

@app.post("/delete")
async def delete(api_key: str = Form(), clinvar_accession: str = Form()):
"""A proxy to the dry run submission ClinVar API endpoint"""
"""A proxy to the submission ClinVar API, to delete a submission with a given ClinVar accession."""
# Create a submission header
header = build_header(api_key)

Expand Down
23 changes: 23 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"assertionCriteriaDB": "PubMed",
"assertionCriteriaID": "25741868",
}
DEMO_ACCESSION_ID = "SCV005395965"


def test_heartbeat():
Expand Down Expand Up @@ -411,3 +412,25 @@ def test_status_submitted():
# THEN the response should contain the provided status
assert response.status_code == 200
assert response.json()["actions"][0]["status"] == "submitted"


@responses.activate
def test_delete():
"""Test the endpoint that deletes ClinVar submissions sing the API."""

# GIVEN a mocked submitted response from ClinVar:
responses.add(
responses.POST,
SUBMISSION_URL,
json={"id": DEMO_SUBMISSION_ID},
status=201,
)

# GIVEN a call to the delete endpoint
response = client.post(
"/delete", data={"api_key": DEMO_API_KEY, "clinvar_accession": DEMO_ACCESSION_ID}
)

# THEN the response should contain the provided status
assert response.status_code == 201
assert response.json()["id"] == DEMO_SUBMISSION_ID

0 comments on commit 1c7c2af

Please sign in to comment.