From 198c76dadccfac4c01579daaf08054fa96fbbc98 Mon Sep 17 00:00:00 2001 From: cszsol Date: Tue, 1 Oct 2024 10:24:43 +0200 Subject: [PATCH] Added change to make tests backwards compatible (#14) * Added change to make tests backwards compatible with new httpx_mock version * Update test_simple_agent.py * Update test_simple_chat_agent.py * Update test_tools.py * Added changelog * Reformatted with proper ruff version --- CHANGELOG.md | 1 + tests/agents/test_simple_chat_agent.py | 2 ++ tests/test_utils.py | 1 + tests/tools/test_electrophys_tool.py | 1 + tests/tools/test_traces_tool.py | 1 + 5 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d71d1fc..e71a0ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed a bug that prevented AsyncSqlite checkpoint to access the DB in streamed endpoints. +- Fixed a bug that caused some unit tests to fail due to a change in how httpx_mock works in version 0.32 ## [0.1.0] - 19.09.2024 diff --git a/tests/agents/test_simple_chat_agent.py b/tests/agents/test_simple_chat_agent.py index c8420a3..c7e0a92 100644 --- a/tests/agents/test_simple_chat_agent.py +++ b/tests/agents/test_simple_chat_agent.py @@ -9,6 +9,7 @@ from neuroagent.agents import AgentOutput, AgentStep, SimpleChatAgent +@pytest.mark.httpx_mock(can_send_already_matched_responses=True) @pytest.mark.asyncio async def test_arun(fake_llm_with_tools, httpx_mock): llm, tools, fake_responses = await anext(fake_llm_with_tools) @@ -64,6 +65,7 @@ async def test_arun(fake_llm_with_tools, httpx_mock): assert len(messages_list) == 10 +@pytest.mark.httpx_mock(can_send_already_matched_responses=True) @pytest.mark.asyncio async def test_astream(fake_llm_with_tools, httpx_mock): llm, tools, fake_responses = await anext(fake_llm_with_tools) diff --git a/tests/test_utils.py b/tests/test_utils.py index 152232c..9e9af8b 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -313,6 +313,7 @@ async def test_get_kg_data_errors(httpx_mock): ) +@pytest.mark.httpx_mock(can_send_already_matched_responses=True) @pytest.mark.asyncio async def test_get_kg_data(httpx_mock): url = "http://fake_url" diff --git a/tests/tools/test_electrophys_tool.py b/tests/tools/test_electrophys_tool.py index e7729fc..6705c2a 100644 --- a/tests/tools/test_electrophys_tool.py +++ b/tests/tools/test_electrophys_tool.py @@ -15,6 +15,7 @@ class TestElectrophysTool: + @pytest.mark.httpx_mock(can_send_already_matched_responses=True) @pytest.mark.asyncio async def test_arun(self, httpx_mock): url = "http://fake_url" diff --git a/tests/tools/test_traces_tool.py b/tests/tools/test_traces_tool.py index 0bae056..d0689aa 100644 --- a/tests/tools/test_traces_tool.py +++ b/tests/tools/test_traces_tool.py @@ -11,6 +11,7 @@ class TestTracesTool: + @pytest.mark.httpx_mock(can_send_already_matched_responses=True) @pytest.mark.asyncio async def test_arun(self, httpx_mock, brain_region_json_path): url = "http://fake_url"