From c4f1b2eb0036988c204e0dcdea3fb876b78c34fb Mon Sep 17 00:00:00 2001 From: Jacob Magar Date: Sat, 14 Mar 2026 14:21:21 -0400 Subject: [PATCH] test(creds): add replacement test for credentials propagation through tool_error_handler --- tests/test_setup.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_setup.py b/tests/test_setup.py index 2b8a123..cfd4fb6 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -385,3 +385,26 @@ def test_tool_error_handler_credentials_error_message_includes_path(): assert str(CREDENTIALS_ENV_PATH) in str(exc_info.value) assert "setup" in str(exc_info.value).lower() + + +@pytest.mark.asyncio +async def test_credentials_not_configured_surfaces_as_tool_error_with_path(): + """CredentialsNotConfiguredError from a tool becomes ToolError with the credentials path.""" + from unittest.mock import AsyncMock, patch + + from tests.conftest import make_tool_fn + from unraid_mcp.config.settings import CREDENTIALS_ENV_PATH + from unraid_mcp.core.exceptions import CredentialsNotConfiguredError, ToolError + + tool_fn = make_tool_fn("unraid_mcp.tools.users", "register_users_tool", "unraid_users") + + with ( + patch( + "unraid_mcp.tools.users.make_graphql_request", + new=AsyncMock(side_effect=CredentialsNotConfiguredError()), + ), + pytest.raises(ToolError) as exc_info, + ): + await tool_fn(action="me") + + assert str(CREDENTIALS_ENV_PATH) in str(exc_info.value)