1818
1919import pytest
2020from fastapi import FastAPI
21+ from pygeoapi .process .base import JobNotFoundError
2122from rs_server_staging .main import (
2223 app_lifespan ,
2324 get_config_contents ,
2829from starlette .status import (
2930 HTTP_200_OK ,
3031 HTTP_404_NOT_FOUND ,
31- HTTP_503_SERVICE_UNAVAILABLE ,
3232 HTTP_500_INTERNAL_SERVER_ERROR ,
33- )
34-
35- from pygeoapi .process .base import (
36- JobNotFoundError ,
37- JobResultNotFoundError ,
38- ProcessorGenericError
33+ HTTP_503_SERVICE_UNAVAILABLE ,
3934)
4035
4136expected_jobs_test = [
@@ -321,7 +316,7 @@ async def test_get_job_result(
321316 """
322317 # Mock app.extra to ensure 'db_table' exists
323318 mock_db_table = mocker .MagicMock ()
324-
319+
325320 if expected_job ["identifier" ] == "non_existing" :
326321 # Simulate JobNotFoundError for non-existing jobs (HTTP 404)
327322 mock_db_table .get_job .side_effect = JobNotFoundError
@@ -340,20 +335,18 @@ async def test_get_job_result(
340335 }
341336 else :
342337 # Return an existing job normally (HTTP 200)
343- job_index = next (
344- i for i , job in enumerate (mock_jobs ) if job ["identifier" ] == expected_job ["identifier" ]
345- )
338+ job_index = next (i for i , job in enumerate (mock_jobs ) if job ["identifier" ] == expected_job ["identifier" ])
346339 mock_db_table .get_job .return_value = mock_jobs [job_index ]
347340 expected_status = HTTP_200_OK
348341 expected_response = expected_job ["status" ]
349-
342+
350343 # Patch app.extra with the mock db_table
351344 mocker .patch .object (staging_client .app , "extra" , {"process_manager" : mock_db_table })
352345
353346 # Call the API
354- job_id = expected_job .get ("identifier" )
347+ job_id = expected_job .get ("identifier" )
355348 response = staging_client .get (f"/jobs/{ job_id } /results" )
356-
349+
357350 # Assert response status code and content
358351 assert response .status_code == expected_status
359352 assert response .json () == expected_response
0 commit comments