@@ -64,7 +64,7 @@ def test_batch_openapi(page):
6464 expect (response ).to_be_ok ()
6565
6666
67- def test_batch_request (unique_id , register_test_user , test_domain ):
67+ def test_batch_request (unique_id , register_test_user , test_domain , docker_compose_exec ):
6868 """A test via the Batch API should succeed."""
6969 request_data = {"type" : "web" , "domains" : [test_domain ], "name" : unique_id }
7070
@@ -129,6 +129,24 @@ def test_batch_request(unique_id, register_test_user, test_domain):
129129 response = requests .get (report_url , verify = False )
130130 assert response .status_code == 200 , "test results should be publicly accessible without authentication"
131131
132+ # delete result files (this can happen in production when cleanup is done by a cron job)
133+ docker_compose_exec ("app" , "sh -c 'rm -v /app/batch_results/*'" )
134+
135+ # try to get batch results again after files have been deleted (this should trigger a new generation task)
136+ results_response = requests .get (INTERNETNL_API + "requests/" + test_id + "/results" , auth = auth , verify = False )
137+ # expect error because result need to be generated again
138+ assert results_response .status_code == 400
139+ assert "Report is being generated." in results_response .text
140+
141+ # wait for report generation and batch to be done
142+ wait_for_request_status (INTERNETNL_API + "requests/" + test_id , "done" , timeout = 60 , auth = auth )
143+
144+ # get batch results again after starting generation
145+ results_response = requests .get (INTERNETNL_API + "requests/" + test_id + "/results" , auth = auth , verify = False )
146+ print (f"{ results_response .text = } " )
147+ results_response .raise_for_status ()
148+ print ("api results JSON:" , results_response .text )
149+
132150
133151def test_batch_static_requires_no_auth ():
134152 """Static files should be available without authentication for viewing batch results."""
0 commit comments