aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/conftest.py10
-rw-r--r--tests/integration/test_partial_correlations.py41
2 files changed, 50 insertions, 1 deletions
diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py
index be58d80..e1d1c37 100644
--- a/tests/integration/conftest.py
+++ b/tests/integration/conftest.py
@@ -1,12 +1,22 @@
+"""Module that holds fixtures for integration tests"""
import pytest
from gn3.app import create_app
+from gn3.db_utils import database_connector
@pytest.fixture(scope="session")
def client():
+ """Create a test client fixture for tests"""
# Do some setup
app = create_app()
app.config.update({"TESTING": True})
app.testing = True
yield app.test_client()
# Do some teardown/cleanup
+
+
+@pytest.fixture
+def db_conn():
+ """Create a db connection fixture for tests"""
+ ## Update this to use temp db once that is in place
+ return database_connector()[0]
diff --git a/tests/integration/test_partial_correlations.py b/tests/integration/test_partial_correlations.py
index ff6d771..7f9ff30 100644
--- a/tests/integration/test_partial_correlations.py
+++ b/tests/integration/test_partial_correlations.py
@@ -1,7 +1,7 @@
"""Test partial correlations"""
import pytest
-from tests.integration.conftest import client
+from gn3.computations.partial_correlations import partial_correlations_entry
@pytest.mark.integration_test
@pytest.mark.parametrize(
@@ -176,3 +176,42 @@ def test_partial_correlation_api_with_non_existent_control_traits(client, post_d
assert (
response.status_code == 404 and response.is_json and
response.json.get("status") != "error")
+
+@pytest.mark.integration_test
+@pytest.mark.slow
+@pytest.mark.parametrize(
+ "primary,controls,method,target", (
+ (# Probeset
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM103710672", (
+ "UCLA_BXDBXH_CARTILAGE_V2::nonExisting01",
+ "UCLA_BXDBXH_CARTILAGE_V2::nonExisting02",
+ "UCLA_BXDBXH_CARTILAGE_V2::ILM380019"),
+ "Genetic Correlation, Pearson's r", "BXDPublish"),
+ (# Publish
+ "BXDPublish::17937", (
+ "BXDPublish::17940",
+ "BXDPublish::nonExisting03"),
+ "Genetic Correlation, Spearman's rho", "BXDPublish"),
+ (# Geno
+ "AKXDGeno::D4Mit16", (
+ "AKXDGeno::D1Mit170",
+ "AKXDGeno::nonExisting04",
+ "AKXDGeno::D1Mit135",
+ "AKXDGeno::nonExisting05",
+ "AKXDGeno::nonExisting06"),
+ "SGO Literature Correlation", "BXDPublish")
+ )
+ # Temp -- the data in the database for these is ephemeral, making it
+ # difficult to test for these without a temp database with the temp
+ # traits data set to something we are in control of
+ )
+def test_part_corr_api_with_mix_of_existing_and_non_existing_control_traits(
+ db_conn, primary, controls, method, target):
+ """
+ Check that calling the function with a mix of existing and missing control
+ traits raises an warning.
+ """
+ criteria = 10
+ with pytest.warns(UserWarning):
+ partial_correlations_entry(
+ db_conn, primary, controls, method, criteria, target)