From 955b9b8398d8da5b1b7b890228fd85e2f22e2f06 Mon Sep 17 00:00:00 2001 From: Chiara Rasi Date: Thu, 14 Mar 2024 14:03:21 +0100 Subject: [PATCH] Fixed a couple of tests --- tests/test_main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index e479a67..c209c05 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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 ) @@ -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"