mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-26 13:16:24 +00:00
* feat(search): add Webz news search provider and setup integration * fix(webz): honor caller result limits and clarify page counts * fix(frontend): render Webz search source links * fix(frontend): skip malformed search source entries
29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
"""Webz configuration resolution must not run on the agent event loop."""
|
|
|
|
import json
|
|
import threading
|
|
from types import SimpleNamespace
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_webz_configuration_runs_off_event_loop(monkeypatch):
|
|
import deerflow.community.webz.tools as module
|
|
|
|
loop_thread = threading.get_ident()
|
|
config_threads = []
|
|
|
|
def config():
|
|
config_threads.append(threading.get_ident())
|
|
return SimpleNamespace(get_tool_config=lambda _: SimpleNamespace(model_extra={"api_key": "synthetic-key"}))
|
|
|
|
monkeypatch.setattr(module, "get_app_config", config)
|
|
client_class = httpx.AsyncClient
|
|
transport = httpx.MockTransport(lambda _: httpx.Response(200, json={"results": []}))
|
|
monkeypatch.setattr(module.httpx, "AsyncClient", lambda **kwargs: client_class(transport=transport, **kwargs))
|
|
result = json.loads(await module.web_search_tool.ainvoke({"query": "news"}))
|
|
assert result["results"] == []
|
|
assert config_threads and all(thread != loop_thread for thread in config_threads)
|