diff options
author | Frederick Muriuki Muriithi | 2023-04-06 12:31:05 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-04-06 12:31:05 +0300 |
commit | 17abad9300e4a96a14f94da486ef8307f7d27e06 (patch) | |
tree | 38fe3bfd36be9a821adfc67b83fbbd587ceb8b5e /tests/integration | |
parent | 3d873435f0d464864d4d691d6be4db40931fac05 (diff) | |
download | genenetwork3-17abad9300e4a96a14f94da486ef8307f7d27e06.tar.gz |
Remove deprecated `gn3.db_utils.database_connector` function
Remove the deprecated function and fix a myriad of bugs that arise from
removing the function.
Issue: https://issues.genenetwork.org/issues/bugfix_coupling_current_app_and_db_utils
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/conftest.py | 9 | ||||
-rw-r--r-- | tests/integration/test_correlation.py | 10 |
2 files changed, 10 insertions, 9 deletions
diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index c953d84..795c42d 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -4,7 +4,7 @@ import MySQLdb from gn3.app import create_app from gn3.chancy import random_string -from gn3.db_utils import parse_db_url, database_connector +from gn3.db_utils import parse_db_url, database_connection @pytest.fixture(scope="session") def client(): @@ -18,17 +18,18 @@ def client(): @pytest.fixture(scope="session") -def db_conn(): +def db_conn(client): """Create a db connection fixture for tests""" # 01) Generate random string to append to all test db artifacts for the session + live_db_uri = client.application.config["SQL_URI"] rand_str = random_string(15) - live_db_details = parse_db_url() + live_db_details = parse_db_url(live_db_uri) test_db_name = f"test_{live_db_details[3]}_{rand_str}" # # 02) Create new test db # Use context manager to ensure the live connection is automatically # closed on exit - with database_connector() as live_db_conn: + with database_connection(live_db_uri) as live_db_conn: with live_db_conn.cursor() as live_db_cursor: live_db_cursor.execute(f"CREATE DATABASE {test_db_name}") # diff --git a/tests/integration/test_correlation.py b/tests/integration/test_correlation.py index c1d518d..51769b5 100644 --- a/tests/integration/test_correlation.py +++ b/tests/integration/test_correlation.py @@ -65,15 +65,15 @@ class CorrelationIntegrationTest(TestCase): @pytest.mark.integration_test @mock.patch("gn3.api.correlation.compute_all_lit_correlation") - @mock.patch("gn3.api.correlation.database_connector") - def test_lit_correlation(self, database_connector, mock_compute_corr): + @mock.patch("gn3.api.correlation.database_connection") + def test_lit_correlation(self, database_connection, mock_compute_corr): """Test api/correlation/lit_corr/{species}/{gene_id}""" mock_compute_corr.return_value = [] - database_connector.return_value = mock.Mock() - database_connector.return_value.__enter__ = mock.Mock() - database_connector.return_value.__exit__ = mock.Mock() + database_connection.return_value = mock.Mock() + database_connection.return_value.__enter__ = mock.Mock() + database_connection.return_value.__exit__ = mock.Mock() post_data = {"1426678_at": "68031", "1426679_at": "68036", |