|
3 | 3 | from typing import Any |
4 | 4 |
|
5 | 5 | import pytest |
| 6 | +from uipath.core.errors import ErrorCategory, UiPathFaultedTriggerError |
6 | 7 |
|
7 | 8 | from uipath.runtime.context import UiPathRuntimeContext |
8 | 9 | from uipath.runtime.errors import ( |
@@ -236,6 +237,38 @@ def test_from_config_loads_runtime_and_fps_properties(tmp_path: Path) -> None: |
236 | 237 | assert ctx.mcp_server_slug == "test-server-slug" |
237 | 238 |
|
238 | 239 |
|
| 240 | +def test_result_file_written_on_faulted_trigger_error(tmp_path: Path) -> None: |
| 241 | + runtime_dir = tmp_path / "runtime" |
| 242 | + ctx = UiPathRuntimeContext( |
| 243 | + job_id="job-trigger-test", |
| 244 | + runtime_dir=str(runtime_dir), |
| 245 | + result_file="result.json", |
| 246 | + ) |
| 247 | + |
| 248 | + trigger_error = UiPathFaultedTriggerError( |
| 249 | + ErrorCategory.SYSTEM, "Failed to create HITL action", "validation error" |
| 250 | + ) |
| 251 | + trigger_error.category = ErrorCategory.SYSTEM |
| 252 | + trigger_error.message = "Failed to create HITL action" |
| 253 | + |
| 254 | + with pytest.raises(UiPathFaultedTriggerError): |
| 255 | + with ctx: |
| 256 | + raise trigger_error |
| 257 | + |
| 258 | + result_path = Path(ctx.resolved_result_file_path) |
| 259 | + assert result_path.exists() |
| 260 | + |
| 261 | + content = json.loads(result_path.read_text()) |
| 262 | + assert content["status"] == UiPathRuntimeStatus.FAULTED.value |
| 263 | + assert "error" in content |
| 264 | + |
| 265 | + error = content["error"] |
| 266 | + assert error["code"] == f"Python.{UiPathErrorCode.RESUME_TRIGGER_ERROR.value}" |
| 267 | + assert error["title"] == "Resume trigger error" |
| 268 | + assert "Failed to create HITL action" in error["detail"] |
| 269 | + assert error["category"] == ErrorCategory.SYSTEM.value |
| 270 | + |
| 271 | + |
239 | 272 | def test_string_output_wrapped_in_dict() -> None: |
240 | 273 | """Test that string output is wrapped in a dict with key 'output'.""" |
241 | 274 | result = UiPathRuntimeResult( |
|
0 commit comments