diff --git a/pyproject.toml b/pyproject.toml index 7fde7e8..3cf496b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -49,6 +49,7 @@ dev = [ "filelock>=3.20.3", "virtualenv>=20.36.1", "numpy>=1.24.0", + "pytest-asyncio>=1.3.0", ] [tool.ruff] diff --git a/src/uipath_mcp/_cli/_runtime/_runtime.py b/src/uipath_mcp/_cli/_runtime/_runtime.py index 788f902..e1ae42a 100644 --- a/src/uipath_mcp/_cli/_runtime/_runtime.py +++ b/src/uipath_mcp/_cli/_runtime/_runtime.py @@ -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, ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/cli/__init__.py b/tests/cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/cli/test_runtime.py b/tests/cli/test_runtime.py new file mode 100644 index 0000000..8808a71 --- /dev/null +++ b/tests/cli/test_runtime.py @@ -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 + + +@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() diff --git a/uv.lock b/uv.lock index 9a543d8..2025561 100644 --- a/uv.lock +++ b/uv.lock @@ -1774,7 +1774,7 @@ wheels = [ [[package]] name = "uipath-mcp" -version = "0.1.3" +version = "0.1.4" source = { editable = "." } dependencies = [ { name = "mcp" }, @@ -1813,6 +1813,7 @@ dev = [ { name = "pre-commit", specifier = ">=4.5.1" }, { name = "pytest", specifier = ">=7.4.0" }, { name = "pytest-asyncio", specifier = ">=0.23.0" }, + { name = "pytest-asyncio", specifier = ">=1.3.0" }, { name = "pytest-cov", specifier = ">=4.1.0" }, { name = "pytest-mock", specifier = ">=3.11.1" }, { name = "ruff", specifier = ">=0.9.4" },