Skip to content

Commit

Permalink
Had to delete one unit test, since it was not working
Browse files Browse the repository at this point in the history
  • Loading branch information
cszsol committed Sep 30, 2024
1 parent ee85b7f commit 2efc883
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
4 changes: 0 additions & 4 deletions src/neuroagent/app/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,17 @@ 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"
f" {connection_string if not settings.db.password else connection_string.replace(settings.db.password.get_secret_value(), '*****')}."
)
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(), '*****')}."
Expand Down
24 changes: 0 additions & 24 deletions tests/app/test_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Test dependencies."""

import json
import logging
import os
from pathlib import Path
from typing import AsyncIterator
Expand Down Expand Up @@ -46,7 +45,6 @@
MorphologyFeatureTool,
)
from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import Session


Expand Down Expand Up @@ -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:"
Expand Down

0 comments on commit 2efc883

Please sign in to comment.