diff --git a/tests/app/test_dependencies.py b/tests/app/test_dependencies.py index 67d3e05..9d1ce93 100644 --- a/tests/app/test_dependencies.py +++ b/tests/app/test_dependencies.py @@ -44,6 +44,7 @@ LiteratureSearchTool, MorphologyFeatureTool, ) +from sqlalchemy import create_engine from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.orm import Session @@ -469,7 +470,8 @@ def test_get_engine_error(create_engine_mock, monkeypatch): @patch("sqlalchemy.orm.Session") def test_get_session_success(_): - engine = Mock() + database_url = "sqlite:///:memory:" + engine = create_engine(database_url) result = next(get_session(engine)) assert isinstance(result, Session) diff --git a/tests/tools/test_base_tool.py b/tests/tools/test_base_tool.py index 1add1eb..fb9ab17 100644 --- a/tests/tools/test_base_tool.py +++ b/tests/tools/test_base_tool.py @@ -1,12 +1,10 @@ from typing import Literal, Type -from unittest.mock import Mock -import pytest from langchain_core.language_models.fake_chat_models import FakeMessagesListChatModel from langchain_core.messages import AIMessage, HumanMessage from langchain_core.tools import ToolException from langgraph.prebuilt import create_react_agent -from neuroagent.tools.base_tool import BasicTool, process_validation_error +from neuroagent.tools.base_tool import BasicTool from pydantic import BaseModel @@ -105,42 +103,3 @@ def bind_tools(self, functions: list): 'unable to parse string as an integer"}]' ) assert response["messages"][7].content == "fake answer" - - -@pytest.mark.parametrize( - "title, errors, expected", - [ - ( - "ValidationError", - [{"type": "literal_error", "input": "distinct", "loc": ["led"]}], - '[{"Validation error": "Wrong value: provided distinct for input led. Try again and change this problematic input."}]', - ), - ( - "ValidationError", - [{"type": "missing", "loc": ["led"]}], - '[{"Validation error": "Missing input : led. Try again and add this input."}]', - ), - ( - "ValidationError", - [ - { - "type": "other_error", - "loc": ["led"], - "msg": "This is a test error message", - } - ], - '[{"Validation error": "led. This is a test error message"}]', - ), - ( - "ValidationError", - [{}], - '[{"Validation error": "Error in ValidationError : \'type\'"}]', - ), - ], -) -def test_process_validation_error(title, errors, expected): - error = Mock() - error.title = title - error.errors.return_value = errors - result = process_validation_error(error) - assert result == expected