Skip to content

Commit 0f3b4eb

Browse files
authored
feat: Allow loading default toolset (all tools) (#153)
* feat: Allow loading default toolset * variable name fix * add tests * test fix
1 parent 2825581 commit 0f3b4eb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/toolbox-core/src/toolbox_core/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async def load_tool(
171171

172172
async def load_toolset(
173173
self,
174-
name: str,
174+
name: Optional[str] = None,
175175
auth_token_getters: dict[str, Callable[[], str]] = {},
176176
bound_params: Mapping[str, Union[Callable[[], Any], Any]] = {},
177177
) -> list[ToolboxTool]:
@@ -192,7 +192,7 @@ async def load_toolset(
192192
in the toolset.
193193
"""
194194
# Request the definition of the tool from the server
195-
url = f"{self.__base_url}/api/toolset/{name}"
195+
url = f"{self.__base_url}/api/toolset/{name or ''}"
196196
async with self.__session.get(url) as response:
197197
json = await response.json()
198198
manifest: ManifestSchema = ManifestSchema(**json)

packages/toolbox-core/tests/test_e2e.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ async def test_load_toolset_specific(
6161
tool_names = {tool.__name__ for tool in toolset}
6262
assert tool_names == set(expected_tools)
6363

64+
async def test_load_toolset_default(self, toolbox: ToolboxClient):
65+
"""Load the default toolset, i.e. all tools."""
66+
toolset = await toolbox.load_toolset()
67+
assert len(toolset) == 5
68+
tool_names = {tool.__name__ for tool in toolset}
69+
expected_tools = [
70+
"get-row-by-content-auth",
71+
"get-row-by-email-auth",
72+
"get-row-by-id-auth",
73+
"get-row-by-id",
74+
"get-n-rows",
75+
]
76+
assert tool_names == set(expected_tools)
77+
6478
async def test_run_tool(self, get_n_rows_tool: ToolboxTool):
6579
"""Invoke a tool."""
6680
response = await get_n_rows_tool(num_rows="2")

0 commit comments

Comments
 (0)