From a7717e1958e1dae26f3abcdd15a6b4b285434624 Mon Sep 17 00:00:00 2001 From: Ian Sillitoe Date: Wed, 24 Jan 2024 14:38:21 +0000 Subject: [PATCH] cx_Oracle -> oracledb --- cath_alphaflow/db_utils.py | 8 ++++---- setup.py | 2 +- tests/conftest.py | 4 ++-- tests/test_db_utils.py | 6 ++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cath_alphaflow/db_utils.py b/cath_alphaflow/db_utils.py index 7a14d96..81d8e24 100644 --- a/cath_alphaflow/db_utils.py +++ b/cath_alphaflow/db_utils.py @@ -1,5 +1,5 @@ import logging -import cx_Oracle +import oracledb as Oracle from cath_alphaflow.settings import get_default_settings from cath_alphaflow.predicted_domain_provider import OraclePredictedCathDomainProvider @@ -15,7 +15,7 @@ DEFAULT_PASSWORD = config.ORACLE_DB_PASSWORD -class OraDB(OraclePredictedCathDomainProvider, cx_Oracle.Connection): +class OraDB(OraclePredictedCathDomainProvider, Oracle.Connection): def __init__( self, host=DEFAULT_HOST, @@ -24,8 +24,8 @@ def __init__( user=DEFAULT_USER, password=DEFAULT_PASSWORD, ): - self._dsn = cx_Oracle.makedsn(host, port, sid=sid) - self._conn = cx_Oracle.connect(user=user, password=password, dsn=self._dsn) + self._dsn = Oracle.makedsn(host, port, sid=sid) + self._conn = Oracle.connect(user=user, password=password, dsn=self._dsn) @property def conn(self): diff --git a/setup.py b/setup.py index 87f2bc9..a6d777f 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def get_long_description(): install_requires=[ "click", "google-cloud-storage", - "cx_oracle", + "oracledb", "prettyconf", "biopython", "pdb-tools", diff --git a/tests/conftest.py b/tests/conftest.py index 205f8dc..ec5b4f2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ from cath_alphaflow import settings import logging import pytest -import cx_Oracle +import oracledb as Oracle from click.testing import CliRunner @@ -97,7 +97,7 @@ def mock_connection(monkeypatch): def mock_connect(*args, **kwargs): return MockConnect() - monkeypatch.setattr(cx_Oracle, "connect", mock_connect) + monkeypatch.setattr(Oracle, "connect", mock_connect) @pytest.fixture diff --git a/tests/test_db_utils.py b/tests/test_db_utils.py index 12986d3..1cef8c1 100644 --- a/tests/test_db_utils.py +++ b/tests/test_db_utils.py @@ -1,7 +1,7 @@ from unittest import mock import logging -import cx_Oracle +import oracledb from cath_alphaflow.db_utils import OraDB from cath_alphaflow.settings import get_default_settings @@ -17,9 +17,8 @@ def test_mock_query(create_mock_query): assert rows == expected_rows -@mock.patch.object(cx_Oracle, "connect") +@mock.patch.object(oracledb, "connect") def test_mock_connection(mock_connect, mock_settings): - settings = get_default_settings() OraDB() @@ -37,7 +36,6 @@ def test_mock_connection(mock_connect, mock_settings): def test_yieldall(create_mock_query): - mock_rows = [ {"cath_code": "1", "description": "Mainly Alpha"}, {"cath_code": "2", "description": "Mainly Beta"},