feat(web): register Keenable provider in WebUI, docs, and tests
Bring the Keenable search provider in line with the established multi-file provider pattern so it surfaces everywhere the others do: - settings_api.py: register in the web-search provider options so it appears in the WebUI settings dropdown (credential: api_key, optional). - WebUI provider-brand: add keenable brand entry + brand test. - docs/configuration.md: provider table row + config example. - Harden _search_keenable: honor config.timeout and return explicit messages on HTTP status errors (429 / other), matching peer providers. - Add env-key and HTTP-error tests; add the websocket settings whitelist assertion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
Xubin Ren
co-authored by
Claude Opus 4.8
parent
4f6e5e9cb8
commit
fa3e902ee8
@@ -178,6 +178,32 @@ async def test_keenable_search_without_key_omits_header(monkeypatch):
|
||||
assert "Anon" in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_keenable_search_uses_env_api_key(monkeypatch):
|
||||
async def mock_post(self, url, **kw):
|
||||
assert kw["headers"]["X-API-Key"] == "env-keen-key"
|
||||
return _response(json={
|
||||
"results": [{"title": "Env", "url": "https://keenable.ai/env", "description": "ok"}]
|
||||
})
|
||||
|
||||
monkeypatch.setattr(httpx.AsyncClient, "post", mock_post)
|
||||
monkeypatch.setenv("KEENABLE_API_KEY", "env-keen-key")
|
||||
tool = _tool(provider="keenable", api_key="")
|
||||
result = await tool.execute(query="keenable", count=1)
|
||||
assert "Env" in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_keenable_search_http_error(monkeypatch):
|
||||
async def mock_post(self, url, **kw):
|
||||
return _response(status=401, json={"error": "invalid key"})
|
||||
|
||||
monkeypatch.setattr(httpx.AsyncClient, "post", mock_post)
|
||||
tool = _tool(provider="keenable", api_key="bad-keen-key")
|
||||
result = await tool.execute(query="keenable")
|
||||
assert "Error: Keenable search failed (401)" in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bocha_search(monkeypatch):
|
||||
async def mock_post(self, url, **kw):
|
||||
|
||||
Reference in New Issue
Block a user