Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
cszsol committed Sep 27, 2024
1 parent 1411b36 commit 65bc474
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
4 changes: 3 additions & 1 deletion tests/app/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
LiteratureSearchTool,
MorphologyFeatureTool,
)
from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import Session

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

Expand Down
43 changes: 1 addition & 42 deletions tests/tools/test_base_tool.py
Original file line number Diff line number Diff line change
@@ -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


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

0 comments on commit 65bc474

Please sign in to comment.