| 
 | 1 | +import json  | 
1 | 2 | import uuid  | 
2 | 3 | from unittest.mock import AsyncMock, patch  | 
3 | 4 | 
 
  | 
@@ -312,3 +313,57 @@ async def test_create_resume_trigger_api(  | 
312 | 313 |         assert resume_trigger.api_resume is not None  | 
313 | 314 |         assert isinstance(resume_trigger.api_resume.inbox_id, str)  | 
314 | 315 |         assert resume_trigger.api_resume.request == api_input  | 
 | 316 | + | 
 | 317 | +    @pytest.mark.anyio  | 
 | 318 | +    async def test_interrupt_with_include_metadata_true_returns_full_action(  | 
 | 319 | +        self,  | 
 | 320 | +        setup_test_env: None,  | 
 | 321 | +    ) -> None:  | 
 | 322 | +        """Test that interrupt() with include_metadata=True returns the whole action object."""  | 
 | 323 | +        action_key = "test-action-key"  | 
 | 324 | + | 
 | 325 | +        # Create an action with include_metadata=True  | 
 | 326 | +        create_action = CreateAction(  | 
 | 327 | +            title="Test Action",  | 
 | 328 | +            app_name="TestApp",  | 
 | 329 | +            app_folder_path="/test/path",  | 
 | 330 | +            data={"input": "test-input"},  | 
 | 331 | +            include_metadata=True,  | 
 | 332 | +        )  | 
 | 333 | + | 
 | 334 | +        # Mock the action that would be retrieved after user interaction  | 
 | 335 | +        mock_action = Action(  | 
 | 336 | +            key=action_key,  | 
 | 337 | +            action="Reject",  | 
 | 338 | +            data={"input": "test-input"},  | 
 | 339 | +            status=2,  | 
 | 340 | +            title="Test Action",  | 
 | 341 | +            id=12345,  | 
 | 342 | +        )  | 
 | 343 | + | 
 | 344 | +        with (  | 
 | 345 | +            patch(  | 
 | 346 | +                "uipath._services.actions_service.ActionsService.create_async"  | 
 | 347 | +            ) as mock_create,  | 
 | 348 | +            patch(  | 
 | 349 | +                "uipath._services.actions_service.ActionsService.retrieve_async"  | 
 | 350 | +            ) as mock_retrieve,  | 
 | 351 | +        ):  | 
 | 352 | +            mock_create.return_value = Action(key=action_key)  | 
 | 353 | +            mock_retrieve.return_value = mock_action  | 
 | 354 | + | 
 | 355 | +            # Simulate interrupt()  | 
 | 356 | +            processor = HitlProcessor(create_action)  | 
 | 357 | +            resume_trigger = await processor.create_resume_trigger()  | 
 | 358 | +            if isinstance(resume_trigger.payload, dict):  | 
 | 359 | +                resume_trigger.payload = json.dumps(resume_trigger.payload)  | 
 | 360 | + | 
 | 361 | +            action_data = await HitlReader.read(resume_trigger)  | 
 | 362 | + | 
 | 363 | +            # verify we got the whole action object  | 
 | 364 | +            assert isinstance(action_data, Action)  | 
 | 365 | +            assert action_data.action == "Reject", "Should contain 'action' field"  | 
 | 366 | +            assert action_data.data == {"input": "test-input"}, (  | 
 | 367 | +                "Should contain correct 'data' field"  | 
 | 368 | +            )  | 
 | 369 | +            assert action_data != mock_action.data  | 
0 commit comments