@@ -993,50 +993,6 @@ def test_job_run_failure_with_timeout_exits_with_code_1_success(self, item_facto
993993 warning_message = mock_print_warning .call_args [0 ][0 ]
994994 assert "timed out" in warning_message
995995
996- def test_job_failure_error_handling_unit_test (self ):
997- """Unit test to verify that FabricCLIError with ERROR_JOB_FAILED is raised when job status is 'Failed'."""
998- from fabric_cli .client .fab_api_types import ApiResponse
999- from fabric_cli .utils .fab_cmd_job_utils import wait_for_job_completion
1000- import json
1001- from unittest .mock import Mock , patch
1002-
1003- # Create mock arguments
1004- job_args = argparse .Namespace (
1005- ws_id = "test-workspace-id" ,
1006- item_id = "test-item-id" ,
1007- command_path = "job run" ,
1008- output_format = "text"
1009- )
1010- job_ins_id = "test-job-instance-id"
1011-
1012- # Create a mock response for the job creation
1013- job_response = Mock (spec = ApiResponse )
1014- job_response .headers = {}
1015-
1016- # Create a failed job status response
1017- failed_job_content = {
1018- "status" : "Failed" ,
1019- "id" : job_ins_id ,
1020- "itemId" : "test-item-id" ,
1021- "jobType" : "RunNotebook" ,
1022- "invokeType" : "Manual" ,
1023- "failureReason" : "Notebook execution failed"
1024- }
1025-
1026- with patch ('fabric_cli.client.fab_api_jobs.get_item_job_instance' ) as mock_get_job :
1027- # Mock the API response for a failed job
1028- mock_response = Mock ()
1029- mock_response .status_code = 200
1030- mock_response .text = json .dumps (failed_job_content )
1031- mock_get_job .return_value = mock_response
1032-
1033- # Verify that the correct exception is raised
1034- with pytest .raises (FabricCLIError ) as exc_info :
1035- wait_for_job_completion (job_args , job_ins_id , job_response )
1036-
1037- # Assert the error details
1038- assert exc_info .value .status_code == constant .ERROR_JOB_FAILED
1039- assert "Job instance 'test-job-instance-id' Failed" in str (exc_info .value .message )
1040996
1041997# region Helper Methods
1042998def job_run (path , params = None , config = None , input = None , timeout = None ):
0 commit comments