Skip to content

Commit 340690e

Browse files
committed
test: add init flow testcase
1 parent f34b8d2 commit 340690e

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

testcases/init-flow/input.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"topic": "uipath"
3+
}

testcases/init-flow/pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "agent"
3+
version = "0.0.1"
4+
description = "agent"
5+
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
6+
dependencies = [
7+
"langchain-anthropic>=0.3.8",
8+
"uipath-langchain",
9+
]
10+
requires-python = ">=3.10"
11+
12+
[tool.uv.sources]
13+
uipath-langchain = { path = "../../", editable = true }

testcases/init-flow/run.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
cd /app/testcases/init-flow
3+
4+
# Sync dependencies for this specific testcase
5+
echo "Syncing dependencies..."
6+
uv sync
7+
8+
echo "Backing up pyproject.toml..."
9+
cp pyproject.toml pyproject-overwrite.toml
10+
11+
echo "Creating new UiPath agent..."
12+
uv run uipath new agent
13+
14+
# uipath new overwrites pyproject.toml, so we need to copy it back
15+
echo "Restoring pyproject.toml..."
16+
cp pyproject-overwrite.toml pyproject.toml
17+
uv sync
18+
19+
echo "Initializing UiPath..."
20+
uv run uipath init
21+
22+
# Authenticate with UiPath
23+
echo "Authenticating with UiPath..."
24+
uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"
25+
26+
# Pack the agent
27+
echo "Packing agent..."
28+
uv run uipath pack
29+
30+
# Run the agent
31+
echo "Input from input.json file"
32+
uv run uipath run agent --file input.json
33+
34+
# Print the output file
35+
source /app/testcases/common/print_output.sh
36+
print_uipath_output
37+
38+
# Validate output
39+
echo "Validating output..."
40+
python src/assert.py || { echo "Validation failed!"; exit 1; }
41+
42+
echo "Testcase completed successfully."

testcases/init-flow/src/assert.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
import json
3+
4+
print("Checking init-flow output...")
5+
6+
# Check NuGet package
7+
uipath_dir = ".uipath"
8+
assert os.path.exists(uipath_dir), "NuGet package directory (.uipath) not found"
9+
10+
nupkg_files = [f for f in os.listdir(uipath_dir) if f.endswith('.nupkg')]
11+
assert nupkg_files, "NuGet package file (.nupkg) not found in .uipath directory"
12+
13+
print(f"NuGet package found: {nupkg_files[0]}")
14+
15+
# Check agent output file
16+
output_file = "__uipath/output.json"
17+
assert os.path.isfile(output_file), "Agent output file not found"
18+
19+
print("Agent output file found")
20+
21+
# Check status and required fields
22+
with open(output_file, 'r', encoding='utf-8') as f:
23+
output_data = json.load(f)
24+
25+
# Check status
26+
status = output_data.get("status")
27+
assert status == "successful", f"Agent execution failed with status: {status}"
28+
29+
print("Agent execution status: successful")
30+
31+
# Check required fields for simple local MCP agent
32+
assert "output" in output_data, "Missing 'output' field in agent response"
33+
34+
output_content = output_data["output"]
35+
assert "messages" in output_content, "Missing 'messages' field in output"
36+
37+
messages = output_content["messages"]
38+
assert messages and isinstance(messages, list), "Messages field is empty or not a list"
39+
40+
print("Required fields validation passed")

0 commit comments

Comments
 (0)