fed8b2eed7
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Backend release / release (push) Has been cancelled
Bandit Security Scan / bandit_scan (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / manifest (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / manifest (push) Has been cancelled
Python linting / ruff (push) Has been cancelled
Run python tests with pytest / Run tests and count coverage (3.12) (push) Has been cancelled
React Widget Build / build (push) Has been cancelled
63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
"""Extra tests for brave tool optional params."""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
|
|
class TestBraveOptionalParams:
|
|
def test_result_filter_added_to_params(self):
|
|
from application.agents.tools.brave import BraveSearchTool
|
|
|
|
tool = BraveSearchTool(config={"token": "tk"})
|
|
fake_response = MagicMock()
|
|
fake_response.status_code = 200
|
|
fake_response.json.return_value = {"web": {"results": []}}
|
|
|
|
with patch(
|
|
"application.agents.tools.brave.requests.get",
|
|
return_value=fake_response,
|
|
) as mock_get:
|
|
tool.execute_action(
|
|
"brave_web_search",
|
|
query="x",
|
|
result_filter="news",
|
|
)
|
|
|
|
# Called with params including result_filter
|
|
params = mock_get.call_args.kwargs["params"]
|
|
assert params.get("result_filter") == "news"
|
|
|
|
def test_extra_snippets_flag(self):
|
|
from application.agents.tools.brave import BraveSearchTool
|
|
|
|
tool = BraveSearchTool(config={"token": "tk"})
|
|
fake_response = MagicMock()
|
|
fake_response.status_code = 200
|
|
fake_response.json.return_value = {"web": {"results": []}}
|
|
|
|
with patch(
|
|
"application.agents.tools.brave.requests.get",
|
|
return_value=fake_response,
|
|
) as mock_get:
|
|
tool.execute_action(
|
|
"brave_web_search", query="x", extra_snippets=True,
|
|
)
|
|
params = mock_get.call_args.kwargs["params"]
|
|
assert params.get("extra_snippets") == 1
|
|
|
|
def test_summary_flag(self):
|
|
from application.agents.tools.brave import BraveSearchTool
|
|
|
|
tool = BraveSearchTool(config={"token": "tk"})
|
|
fake_response = MagicMock()
|
|
fake_response.status_code = 200
|
|
fake_response.json.return_value = {"web": {"results": []}}
|
|
|
|
with patch(
|
|
"application.agents.tools.brave.requests.get",
|
|
return_value=fake_response,
|
|
) as mock_get:
|
|
tool.execute_action("brave_web_search", query="x", summary=True)
|
|
params = mock_get.call_args.kwargs["params"]
|
|
assert params.get("summary") == 1
|