diff --git a/tests/test_agents.py b/tests/test_agents.py index f52e3177..077d5d63 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -313,18 +313,26 @@ async def test_agent_sharing_state( embedding_model = agent_test_settings.get_embedding_model() answer = Answer(question="What is is a self-explanatory model?") - docs = Docs() query = QueryRequest(query=answer.question, settings=agent_test_settings) - env_state = EnvironmentState(docs=docs, answer=answer) + env_state = EnvironmentState(docs=Docs(), answer=answer) + built_index = await get_directory_index(settings=agent_test_settings) + assert await built_index.count, "Index build did not work" with subtests.test(msg=PaperSearch.__name__): search_tool = PaperSearch( settings=agent_test_settings, embedding_model=embedding_model ) - await search_tool.paper_search( - "XAI self explanatory model", min_year=None, max_year=None, state=env_state - ) - assert env_state.docs.docs, "Search did not save any papers" + with patch.object( + SearchIndex, "save_index", autospec=True, wraps=SearchIndex.save_index + ) as mock_save_index: + await search_tool.paper_search( + "XAI self explanatory model", + min_year=None, + max_year=None, + state=env_state, + ) + assert env_state.docs.docs, "Search did not add any papers" + mock_save_index.assert_not_awaited(), "Search shouldn't try to update the index" assert all( (isinstance(d, Doc) or issubclass(d, Doc)) # type: ignore[unreachable] for d in env_state.docs.docs.values()