@@ -51,31 +51,132 @@ def get_http_error_scenarios():
5151 {
5252 "name" : "not_found" ,
5353 "status_code" : 404 ,
54- "text " : " Pipeline not found" ,
54+ "json_data " : { "message" : " Pipeline not found"} ,
5555 "expected_error" : errors .PipelineNotFoundError ,
5656 "error_message" : "not found" ,
5757 },
5858 {
5959 "name" : "forbidden" ,
6060 "status_code" : 403 ,
61- "text " : " Pipeline already active" ,
61+ "json_data " : { "message" : " Pipeline already active"} ,
6262 "expected_error" : errors .PipelineAlreadyExistsError ,
6363 "error_message" : "already exists" ,
6464 },
6565 {
6666 "name" : "bad_request" ,
6767 "status_code" : 400 ,
68- "text " : " Bad request" ,
68+ "json_data " : { "message" : " Bad request"} ,
6969 "expected_error" : errors .ValidationError ,
7070 "error_message" : "Bad request" ,
7171 },
7272 {
7373 "name" : "server_error" ,
7474 "status_code" : 500 ,
75- "text " : " Internal server error" ,
75+ "json_data " : { "message" : " Internal server error"} ,
7676 "expected_error" : errors .ServerError ,
7777 "error_message" : "Internal server error" ,
7878 },
79+ # Status validation error scenarios for 400 Bad Request responses
80+ {
81+ "name" : "terminal_state_violation" ,
82+ "status_code" : 400 ,
83+ "json_data" : {
84+ "message" : (
85+ "Cannot transition from terminal state Terminated to Running"
86+ ),
87+ "code" : "TERMINAL_STATE_VIOLATION" ,
88+ "current_status" : "Terminated" ,
89+ "requested_status" : "Running" ,
90+ },
91+ "expected_error" : errors .TerminalStateViolationError ,
92+ "error_message" : (
93+ "Cannot transition from terminal state Terminated to Running"
94+ ),
95+ },
96+ {
97+ "name" : "invalid_status_transition" ,
98+ "status_code" : 400 ,
99+ "json_data" : {
100+ "message" : "Invalid status transition from Running to Paused" ,
101+ "code" : "INVALID_STATUS_TRANSITION" ,
102+ "current_status" : "Running" ,
103+ "requested_status" : "Paused" ,
104+ "valid_transitions" : ["Stopping" , "Terminating" ],
105+ },
106+ "expected_error" : errors .InvalidStatusTransitionError ,
107+ "error_message" : "Invalid status transition from Running to Paused" ,
108+ },
109+ {
110+ "name" : "unknown_status" ,
111+ "status_code" : 400 ,
112+ "json_data" : {
113+ "message" : "Unknown pipeline status: InvalidStatus" ,
114+ "code" : "UNKNOWN_STATUS" ,
115+ "current_status" : "InvalidStatus" ,
116+ },
117+ "expected_error" : errors .UnknownStatusError ,
118+ "error_message" : "Unknown pipeline status: InvalidStatus" ,
119+ },
120+ {
121+ "name" : "pipeline_already_in_state" ,
122+ "status_code" : 400 ,
123+ "json_data" : {
124+ "message" : "Pipeline is already in Running state" ,
125+ "code" : "PIPELINE_ALREADY_IN_STATE" ,
126+ "current_status" : "Running" ,
127+ "requested_status" : "Running" ,
128+ },
129+ "expected_error" : errors .PipelineAlreadyInStateError ,
130+ "error_message" : "Pipeline is already in Running state" ,
131+ },
132+ {
133+ "name" : "pipeline_in_transition" ,
134+ "status_code" : 400 ,
135+ "json_data" : {
136+ "message" : (
137+ "Pipeline is currently transitioning from Pausing state, "
138+ "cannot perform Stopping operation"
139+ ),
140+ "code" : "PIPELINE_IN_TRANSITION" ,
141+ "current_status" : "Pausing" ,
142+ "requested_status" : "Stopping" ,
143+ },
144+ "expected_error" : errors .PipelineInTransitionError ,
145+ "error_message" : (
146+ "Pipeline is currently transitioning from Pausing state, "
147+ "cannot perform Stopping operation"
148+ ),
149+ },
150+ {
151+ "name" : "invalid_json" ,
152+ "status_code" : 400 ,
153+ "json_data" : {"message" : "invalid json: unexpected end of JSON input" },
154+ "expected_error" : errors .InvalidJsonError ,
155+ "error_message" : "invalid json: unexpected end of JSON input" ,
156+ },
157+ {
158+ "name" : "empty_pipeline_id" ,
159+ "status_code" : 400 ,
160+ "json_data" : {"message" : "pipeline id cannot be empty" },
161+ "expected_error" : errors .EmptyPipelineIdError ,
162+ "error_message" : "pipeline id cannot be empty" ,
163+ },
164+ {
165+ "name" : "pipeline_deletion_state_violation" ,
166+ "status_code" : 400 ,
167+ "json_data" : {
168+ "message" : (
169+ "pipeline can only be deleted if it's stopped or terminated, "
170+ "current status: Running"
171+ ),
172+ "field" : {"current_status" : "Running" },
173+ },
174+ "expected_error" : errors .PipelineDeletionStateViolationError ,
175+ "error_message" : (
176+ "pipeline can only be deleted if it's stopped or terminated, "
177+ "current status: Running"
178+ ),
179+ },
79180 ]
80181
81182
0 commit comments