Skip to content

Commit 63ff0fd

Browse files
authored
test: tavily - add 2 unit tests (#3222)
1 parent 59a2f4c commit 63ff0fd

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

integrations/tavily/tests/test_tavily_websearch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ def test_run_empty_results(self, mock_client):
164164
assert result["documents"] == []
165165
assert result["links"] == []
166166

167+
def test_run_raises_runtime_error_when_warm_up_fails_to_initialize_client(self, monkeypatch):
168+
ws = TavilyWebSearch(api_key=Secret.from_token("test-key"))
169+
monkeypatch.setattr(ws, "warm_up", lambda: None)
170+
with pytest.raises(RuntimeError, match="TavilyWebSearch client failed to initialize"):
171+
ws.run(query="test")
172+
173+
@pytest.mark.asyncio
174+
async def test_run_async_raises_runtime_error_when_warm_up_fails_to_initialize_client(self, monkeypatch):
175+
ws = TavilyWebSearch(api_key=Secret.from_token("test-key"))
176+
monkeypatch.setattr(ws, "warm_up", lambda: None)
177+
with pytest.raises(RuntimeError, match="TavilyWebSearch async client failed to initialize"):
178+
await ws.run_async(query="test")
179+
167180
@pytest.mark.skipif(
168181
not os.environ.get("TAVILY_API_KEY"),
169182
reason="Export TAVILY_API_KEY to run integration tests.",

0 commit comments

Comments
 (0)