2929from starlette .status import (
3030 HTTP_200_OK ,
3131 HTTP_404_NOT_FOUND ,
32- HTTP_500_INTERNAL_SERVER_ERROR ,
3332 HTTP_503_SERVICE_UNAVAILABLE ,
3433)
3534
@@ -226,12 +225,7 @@ async def test_get_jobs_endpoint(mocker, set_db_env_var, staging_client): # pyl
226225 (
227226 {"identifier" : "non_existing_id" },
228227 HTTP_404_NOT_FOUND ,
229- {"title" : "No Such Job" , "detail" : "Job with ID non_existing_id not found" },
230- ),
231- (
232- {"identifier" : "trigger_500" },
233- HTTP_500_INTERNAL_SERVER_ERROR ,
234- {"title" : "Internal Server Error" , "detail" : "Unexpected error occurred" },
228+ {"message" : "Job with ID non_existing_id not found" },
235229 ),
236230 * [(job , HTTP_200_OK , job ) for job in expected_jobs_test ],
237231 ],
@@ -265,17 +259,13 @@ async def test_get_job(
265259 - Asserts that the response status code is 200 and the returned job
266260 details match the expected job dictionary when the job exists.
267261 - Asserts that the response status code is 404 when the job does not exist.
268- - Asserts that the response status code is 500 if other exception occurs.
269262 """
270263 # Mock app.extra to ensure 'db_table' exists
271264 mock_db_table = mocker .MagicMock ()
272265
273266 # Simulate JobNotFoundError for non-existing jobs (HTTP 404)
274267 if expected_status == HTTP_404_NOT_FOUND :
275268 mock_db_table .get_job .side_effect = JobNotFoundError
276- # Simulate an unexpected exception (HTTP 500)
277- elif expected_status == HTTP_500_INTERNAL_SERVER_ERROR :
278- mock_db_table .get_job .side_effect = Exception ("Unexpected error occurred" )
279269 # Return an existing job normally (HTTP 200)
280270 else :
281271 mock_db_table .get_job .return_value = next (
@@ -300,12 +290,7 @@ async def test_get_job(
300290 (
301291 {"identifier" : "non_existing_id" },
302292 HTTP_404_NOT_FOUND ,
303- {"title" : "No Such Job" , "detail" : "Job with ID non_existing_id not found" },
304- ),
305- (
306- {"identifier" : "trigger_500" },
307- HTTP_500_INTERNAL_SERVER_ERROR ,
308- {"title" : "Internal Server Error" , "detail" : "Unexpected error occurred" },
293+ {"message" : "Job with ID non_existing_id not found" },
309294 ),
310295 * [(job , HTTP_200_OK , job ["status" ]) for job in expected_jobs_test ],
311296 ],
@@ -339,17 +324,13 @@ async def test_get_job_result(
339324 - Asserts that the response status code is 200 and the returned job result
340325 matches the expected job status when the job exists.
341326 - Asserts that the response status code is 404 when the job does not exist.
342- - Asserts that the response status code is 500 if other exception occurs.
343327 """
344328 # Mock app.extra to ensure 'db_table' exists
345329 mock_db_table = mocker .MagicMock ()
346330
347331 # Simulate JobNotFoundError for non-existing jobs (HTTP 404)
348332 if expected_status == HTTP_404_NOT_FOUND :
349333 mock_db_table .get_job .side_effect = JobNotFoundError
350- # Simulate an unexpected exception (HTTP 500)
351- elif expected_status == HTTP_500_INTERNAL_SERVER_ERROR :
352- mock_db_table .get_job .side_effect = Exception ("Unexpected error occurred" )
353334 # Return an existing job normally (HTTP 200)
354335 else :
355336 mock_db_table .get_job .return_value = next (
@@ -375,12 +356,7 @@ async def test_get_job_result(
375356 (
376357 {"identifier" : "non_existing_id" },
377358 HTTP_404_NOT_FOUND ,
378- {"title" : "No Such Job" , "detail" : "Job with ID non_existing_id not found" },
379- ),
380- (
381- {"identifier" : "trigger_500" },
382- HTTP_500_INTERNAL_SERVER_ERROR ,
383- {"title" : "Internal Server Error" , "detail" : "Unexpected error occurred" },
359+ {"message" : "Job with ID non_existing_id not found" },
384360 ),
385361 * [
386362 (job , HTTP_200_OK , {"message" : f"Job { job ['identifier' ]} deleted successfully" })
@@ -424,9 +400,6 @@ async def test_delete_job_endpoint(
424400 # Simulate JobNotFoundError for non-existing jobs (HTTP 404)
425401 if expected_status == HTTP_404_NOT_FOUND :
426402 mock_db_table .delete_job .side_effect = JobNotFoundError
427- # Simulate an unexpected exception (HTTP 500)
428- elif expected_status == HTTP_500_INTERNAL_SERVER_ERROR :
429- mock_db_table .delete_job .side_effect = Exception ("Unexpected error occurred" )
430403 # Return an existing job normally (HTTP 200)
431404 else :
432405 mock_db_table .delete_job .return_value = next (
0 commit comments