Skip to content

Commit ebe4cb6

Browse files
committed
test2
1 parent 43bd757 commit ebe4cb6

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

testcases/ground-to-cloud/run.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,21 @@ uv sync
1818
echo "Authenticating with UiPath..."
1919
uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"
2020

21-
# Remove empty tenantId line if exists
22-
sed -i '/^UIPATH_TENANT_ID=[[:space:]]*$/d' .env
23-
2421
# Generate dynamic values
2522
PR_NUMBER=${GITHUB_PR_NUMBER:-"local"}
26-
#UNIQUE_ID=$(python -c "import uuid; print(str(uuid.uuid4()))" 2>/dev/null || python3 -c "import uuid; print(str(uuid.uuid4()))")
2723
UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid)
2824
MCP_SERVER_NAME="mathmcp-${PR_NUMBER}"
2925

30-
echo "Updating uipath.json with dynamic values..."
31-
echo "PR Number: $PR_NUMBER"
32-
echo "MCP Server Name: $MCP_SERVER_NAME"
33-
echo "Unique ID: $UNIQUE_ID"
26+
echo "Updating uipath.json with dynamic values... PR Number: $PR_NUMBER, MCP Server Name: $MCP_SERVER_NAME, Unique ID: $UNIQUE_ID"
27+
28+
# Remove empty tenantId line if exists
29+
sed -i '/^UIPATH_TENANT_ID=[[:space:]]*$/d' .env
3430

3531
# Replace placeholders in uipath.json using sed
32+
sed -i "s/PRNUMBER/$PR_NUMBER/g" mcp.json
3633
sed -i "s/PRNUMBER/$PR_NUMBER/g" uipath.json
3734
sed -i "s/163f06b8-31e6-4639-aa31-ae4a88968a92/$UNIQUE_ID/g" uipath.json
3835

39-
sed -i "s/PRNUMBER/$PR_NUMBER/g" mcp.json
40-
4136
echo "Packing agent..."
4237
uv run uipath pack
4338

testcases/ground-to-cloud/test.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def get_required_env_var(name: str) -> str:
1717

1818
@retry(tries=3, delay=2, backoff=2)
1919
async def call_add_tool():
20-
load_dotenv()
2120
# Load configuration from environment variables
2221
base_url = get_required_env_var("BASE_URL")
2322
folder_key = get_required_env_var("UIPATH_FOLDER_KEY")
@@ -27,37 +26,42 @@ async def call_add_tool():
2726
# Construct the MCP server URL
2827
mcp_url = f"{base_url}/agenthub_/mcp/{folder_key}/{mcp_server_name}"
2928

30-
# Use streamable HTTP client to connect to the MCP server
31-
async with streamablehttp_client(mcp_url, headers={ 'Authorization': f'Bearer {token}' }) as (read_stream, write_stream, _):
32-
async with ClientSession(read_stream, write_stream) as session:
33-
# Initialize the session
34-
await session.initialize()
35-
36-
# List available tools
37-
tools_result = await session.list_tools()
38-
available_tools = [tool.name for tool in tools_result.tools]
39-
expected_available_tools = [ "add", "subtract", "multiply", "divide", "power", "square_root", "nth_root", "sin", "cos", "tan", "log10", "natural_log", "log_base", "mean", "median", "standard_deviation", "complex_add", "complex_multiply", "convert_temperature", "solve_quadratic", "get_constants" ]
40-
41-
print (f"Available tools: {available_tools}")
29+
try:
30+
# Use streamable HTTP client to connect to the MCP server
31+
async with streamablehttp_client(mcp_url, headers={ 'Authorization': f'Bearer {token}' }) as (read_stream, write_stream, _):
32+
async with ClientSession(read_stream, write_stream) as session:
33+
# Initialize the session
34+
await session.initialize()
35+
36+
# List available tools
37+
tools_result = await session.list_tools()
38+
available_tools = [tool.name for tool in tools_result.tools]
39+
expected_available_tools = [ "add", "subtract", "multiply", "divide", "power", "square_root", "nth_root", "sin", "cos", "tan", "log10", "natural_log", "log_base", "mean", "median", "standard_deviation", "complex_add", "complex_multiply", "convert_temperature", "solve_quadratic", "get_constants" ]
4240

43-
if set(available_tools) != set(expected_available_tools):
44-
raise AssertionError(f"Tool sets don't match. Expected: {set(expected_available_tools)}, Got: {set(available_tools)}")
41+
print (f"Available tools: {available_tools}")
4542

46-
# Call the add tool directly
47-
call_tool_result = await session.call_tool(name="add", arguments={"a": 7, "b": 5})
43+
if set(available_tools) != set(expected_available_tools):
44+
raise AssertionError(f"Tool sets don't match. Expected: {set(expected_available_tools)}, Got: {set(available_tools)}")
4845

49-
expected_result = "12.0"
50-
actual_result = call_tool_result.content[0].text if call_tool_result.content else None
46+
# Call the add tool directly
47+
call_tool_result = await session.call_tool(name="add", arguments={"a": 7, "b": 5})
5148

52-
if actual_result != expected_result:
53-
raise AssertionError(f"Expected {expected_result}, got {actual_result}")
49+
expected_result = "12.0"
50+
actual_result = call_tool_result.content[0].text if call_tool_result.content else None
5451

55-
print("Test completed successfully")
52+
if actual_result != expected_result:
53+
raise AssertionError(f"Expected {expected_result}, got {actual_result}")
5654

55+
print("Test completed successfully")
56+
except Exception as e:
57+
print(f"Unexpected error connecting to MCP server: {e}")
58+
raise AssertionError(f"Connection error, {e}") from e
5759

5860
async def main():
5961
"""Main async function to run the test."""
6062
try:
63+
load_dotenv()
64+
6165
await call_add_tool()
6266
except Exception as e:
6367
print(f"Test failed with error: {e}")

0 commit comments

Comments
 (0)