From 12db8134081bc679565dfff1aaa2da81f913dd9d Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 14 Feb 2022 14:35:29 +0300 Subject: Test partial correlations endpoint with missing data in POST request Add a test for the partial correlations endpoint, with: - no data in the request - missing items in the data Fix the bugs caught by the test --- tests/integration/test_partial_correlations.py | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/integration/test_partial_correlations.py (limited to 'tests') diff --git a/tests/integration/test_partial_correlations.py b/tests/integration/test_partial_correlations.py new file mode 100644 index 0000000..5b520e0 --- /dev/null +++ b/tests/integration/test_partial_correlations.py @@ -0,0 +1,90 @@ +"""Test partial correlations""" +import pytest + +from tests.integration.conftest import client + +@pytest.mark.integration_test +@pytest.mark.parametrize( + "post_data", ( + None, {}, { + "primary_trait": None, + "control_traits": None, + "method": None, + "target_db": None + }, { + "primary_trait": None, + "control_traits": None, + "method": None, + "target_db": "a_db" + }, { + "primary_trait": None, + "control_traits": None, + "method": "a_method", + "target_db": None + }, { + "primary_trait": None, + "control_traits": None, + "method": "a_method", + "target_db": "a_db" + }, { + "primary_trait": None, + "control_traits": ["a_trait", "another"], + "method": None, + "target_db": None + }, { + "primary_trait": None, + "control_traits": ["a_trait", "another"], + "method": None, + "target_db": "a_db" + }, { + "primary_trait": None, + "control_traits": ["a_trait", "another"], + "method": "a_method", + "target_db": None + }, { + "primary_trait": None, + "control_traits": ["a_trait", "another"], + "method": "a_method", + "target_db": "a_db" + }, { + "primary_trait": "a_trait", + "control_traits": None, + "method": None, + "target_db": None + }, { + "primary_trait": "a_trait", + "control_traits": None, + "method": None, + "target_db": "a_db" + }, { + "primary_trait": "a_trait", + "control_traits": None, + "method": "a_method", + "target_db": None + }, { + "primary_trait": "a_trait", + "control_traits": None, + "method": "a_method", + "target_db": "a_db" + }, { + "primary_trait": "a_trait", + "control_traits": ["a_trait", "another"], + "method": None, + "target_db": None + }, { + "primary_trait": "a_trait", + "control_traits": ["a_trait", "another"], + "method": None, + "target_db": "a_db" + }, { + "primary_trait": "a_trait", + "control_traits": ["a_trait", "another"], + "method": "a_method", + "target_db": None + })) +def test_partial_correlation_api_with_missing_request_data(client, post_data): + "Test /api/correlations/partial" + response = client.post("/api/correlation/partial", json=post_data) + assert ( + response.status_code == 400 and response.is_json and + response.json.get("status") == "error") -- cgit v1.2.3