Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-mcp"
version = "0.1.3"
version = "0.1.4"
description = "UiPath MCP SDK"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down Expand Up @@ -49,6 +49,7 @@ dev = [
"filelock>=3.20.3",
"virtualenv>=20.36.1",
"numpy>=1.24.0",
"pytest-asyncio>=1.3.0",
]

[tool.ruff]
Expand Down
2 changes: 1 addition & 1 deletion src/uipath_mcp/_cli/_runtime/_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async def _run_server(self) -> UiPathRuntimeResult:
raise UiPathMcpRuntimeError(
McpErrorCode.REGISTRATION_ERROR,
"Folder NOT FOUND. Invalid UIPATH_FOLDER_PATH environment variable.",
"Please set the UIPATH_FOLDER_PATH or UIPATH_FOLDER_KEY environment variable.",
f"The folder '{folder_path}' was not found. Please verify that UIPATH_FOLDER_PATH is set to a valid folder path, or use UIPATH_FOLDER_KEY instead.",
UiPathErrorCategory.USER,
)

Expand Down
Empty file added tests/__init__.py
Empty file.
Empty file added tests/cli/__init__.py
Empty file.
49 changes: 49 additions & 0 deletions tests/cli/test_runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from unittest.mock import MagicMock, patch

import pytest
from uipath._utils.constants import ENV_FOLDER_PATH

from uipath_mcp._cli._runtime._exception import UiPathMcpRuntimeError
from uipath_mcp._cli._runtime._runtime import UiPathMcpRuntime


@pytest.fixture
def runtime():
with patch("uipath_mcp._cli._runtime._runtime.UiPath"):
rt = UiPathMcpRuntime(
server=MagicMock(),
runtime_id="test-runtime-id",
entrypoint="test-entrypoint",
)
rt._uipath = MagicMock()
return rt
Comment on lines +10 to +19
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these tests, runtime._run_server() will always execute the finally: await self._cleanup() path. _cleanup() calls _on_runtime_abort(), which does await self._uipath.api_client.request_async(...). Since the fixture sets rt._uipath = MagicMock(), request_async will be a plain MagicMock (not awaitable) and can raise a TypeError, masking the intended UiPathMcpRuntimeError and making the tests flaky/failing. Consider either stubbing runtime._cleanup / _on_runtime_abort in the tests, or setting runtime._uipath.api_client.request_async to an AsyncMock returning a response object with status_code/text.

Copilot uses AI. Check for mistakes.


@pytest.mark.asyncio
async def test_folder_path_missing_raises_error(runtime):
"""Error when UIPATH_FOLDER_PATH is not set at all."""
with (
patch.object(runtime, "_validate_auth"),
patch.dict("os.environ", {}, clear=True),
pytest.raises(UiPathMcpRuntimeError) as exc_info,
):
await runtime._run_server()

assert "Please set the UIPATH_FOLDER_PATH" in str(exc_info.value)


@pytest.mark.asyncio
async def test_folder_path_not_found_raises_error(runtime):
"""Error when UIPATH_FOLDER_PATH is set but the folder doesn't exist."""
runtime._uipath.folders.retrieve_key.return_value = None

with (
patch.object(runtime, "_validate_auth"),
patch.dict("os.environ", {ENV_FOLDER_PATH: "NonExistent/Folder"}, clear=True),
pytest.raises(UiPathMcpRuntimeError) as exc_info,
):
await runtime._run_server()

error_msg = str(exc_info.value)
assert "NonExistent/Folder" in error_msg
assert "not found" in error_msg.lower()
3 changes: 2 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.