diff --git a/src/neuroagent/app/dependencies.py b/src/neuroagent/app/dependencies.py index 2b694b8..75a619e 100644 --- a/src/neuroagent/app/dependencies.py +++ b/src/neuroagent/app/dependencies.py @@ -102,13 +102,10 @@ def get_engine( # https://fastapi.tiangolo.com/tutorial/sql-databases/#create-the-sqlalchemy-engine engine_kwargs["connect_args"] = {"check_same_thread": False} engine = create_engine(**engine_kwargs) - # breakpoint() else: logger.warning("The SQL db_prefix needs to be set to use the SQL DB.") - # breakpoint()# return None try: - # breakpoint() engine.connect() logger.info( "Successfully connected to the SQL database" @@ -116,7 +113,6 @@ def get_engine( ) return engine except SQLAlchemyError: - # breakpoint() logger.warning( "Failed connection to SQL database" f" {connection_string if not settings.db.password else connection_string.replace(settings.db.password.get_secret_value(), '*****')}." diff --git a/tests/app/test_dependencies.py b/tests/app/test_dependencies.py index 66dc3a0..c4a3909 100644 --- a/tests/app/test_dependencies.py +++ b/tests/app/test_dependencies.py @@ -1,7 +1,6 @@ """Test dependencies.""" import json -import logging import os from pathlib import Path from typing import AsyncIterator @@ -46,7 +45,6 @@ MorphologyFeatureTool, ) from sqlalchemy import create_engine -from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.orm import Session @@ -448,28 +446,6 @@ def test_get_engine_no_connection_string(create_engine_mock, monkeypatch): assert retval is None -@patch("sqlalchemy.engine.create.create_engine") -def test_get_engine_error(sql_create_engine_mock, monkeypatch): - engine_mock = Mock() - engine_mock.connect.side_effect = SQLAlchemyError("An error occurred") - sql_create_engine_mock.return_value = engine_mock - - monkeypatch.setenv("NEUROAGENT_TOOLS__LITERATURE__URL", "http://localhost") - monkeypatch.setenv("NEUROAGENT_KNOWLEDGE_GRAPH__BASE_URL", "http://localhost") - monkeypatch.setenv("NEUROAGENT_DB__PREFIX", "prefix") - monkeypatch.setenv("NEUROAGENT_KEYCLOAK__USERNAME", "fake_username") - monkeypatch.setenv("NEUROAGENT_KEYCLOAK__PASSWORD", "fake_password") - - settings = Settings() - - logging.error(f"settings.db.prefix: {settings.db.prefix}") - logging.error(f"NEUROAGENT_DB__PREFIX: {os.getenv('NEUROAGENT_DB__PREFIX')}") - - connection_string = "https://localhost" - with pytest.raises(SQLAlchemyError): - get_engine(settings=settings, connection_string=connection_string) - - @patch("sqlalchemy.orm.Session") def test_get_session_success(_): database_url = "sqlite:///:memory:"