Skip to content

Commit

Permalink
Fixed a couple of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiara Rasi committed Mar 14, 2024
1 parent e290c8d commit 955b9b8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ def test_dry_run():
responses.add(
responses.POST,
DRY_RUN_SUBMISSION_URL,
json={},
status=204, # The ClinVar API returns 204 (no content) when a dry-run submission was successful and no submission was created
)

Expand All @@ -290,15 +289,24 @@ def test_dry_run():
assert response.json()["message"] == "success"


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

# GIVEN a json submission file
json_file = {"json_file": open(subm_json_path, "rb")}

# AND a mocked ClinVar API
responses.add(
responses.POST,
VALIDATE_SUBMISSION_URL,
json={"message": "No valid API key provided"},
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)

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

Expand Down

0 comments on commit 955b9b8

Please sign in to comment.