Skip to content

Commit ccb8f96

Browse files
committed
chore: Cover tool not found case
1 parent e034d57 commit ccb8f96

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/toolbox-core/tests/test_client.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,32 @@ def token_handler_2():
407407
match=f"Authentication source\\(s\\) `{AUTH_SERVICE}` already registered in tool `{TOOL_NAME}`.",
408408
):
409409
authed_tool.add_auth_token_getters({AUTH_SERVICE: token_handler_2})
410+
411+
412+
@pytest.mark.asyncio
413+
async def test_load_tool_not_found_in_manifest(aioresponses, test_tool_str):
414+
"""
415+
Tests that load_tool raises an Exception when the requested tool name
416+
is not found in the manifest returned by the server, using existing fixtures.
417+
"""
418+
ACTUAL_TOOL_IN_MANIFEST = "actual_tool_abc"
419+
REQUESTED_TOOL_NAME = "non_existent_tool_xyz"
420+
421+
manifest = ManifestSchema(
422+
serverVersion="0.0.0",
423+
tools={ACTUAL_TOOL_IN_MANIFEST: test_tool_str}
424+
)
425+
426+
aioresponses.get(
427+
f"{TEST_BASE_URL}/api/tool/{REQUESTED_TOOL_NAME}",
428+
payload=manifest.model_dump(),
429+
status=200,
430+
)
431+
432+
async with ToolboxClient(TEST_BASE_URL) as client:
433+
with pytest.raises(Exception, match=f"Tool '{REQUESTED_TOOL_NAME}' not found!"):
434+
await client.load_tool(REQUESTED_TOOL_NAME)
435+
436+
aioresponses.assert_called_once_with(
437+
f"{TEST_BASE_URL}/api/tool/{REQUESTED_TOOL_NAME}", method='GET'
438+
)

0 commit comments

Comments
 (0)