Skip to content

Commit 9889975

Browse files
committed
chore: Add unit test cases
1 parent 1f010b0 commit 9889975

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
@@ -372,6 +372,35 @@ async def test_add_auth_token_getters_duplicate_fail(self, tool_name, client):
372372
authed_tool.add_auth_token_getters({AUTH_SERVICE: {}})
373373

374374

375+
@pytest.mark.asyncio
376+
async def test_add_auth_token_getters_missing_fail(self, tool_name, client):
377+
"""
378+
Tests that adding a missing auth token getter raises ValueError.
379+
"""
380+
AUTH_SERVICE = "xmy-auth-service"
381+
382+
tool = await client.load_tool(tool_name)
383+
384+
with pytest.raises(
385+
ValueError,
386+
match=f"Authentication source\(s\) \`{AUTH_SERVICE}\` unused by tool \`{tool_name}\`.",
387+
):
388+
tool.add_auth_token_getters({AUTH_SERVICE: {}})
389+
390+
@pytest.mark.asyncio
391+
async def test_constructor_getters_missing_fail(self, tool_name, client):
392+
"""
393+
Tests that adding a missing auth token getter raises ValueError.
394+
"""
395+
AUTH_SERVICE = "xmy-auth-service"
396+
397+
with pytest.raises(
398+
ValueError,
399+
match=f"Validation failed for tool '{tool_name}': unused auth tokens: {AUTH_SERVICE}.",
400+
):
401+
await client.load_tool(tool_name, auth_token_getters={AUTH_SERVICE: {}})
402+
403+
375404
class TestBoundParameter:
376405

377406
@pytest.fixture

0 commit comments

Comments
 (0)