Skip to content

Commit

Permalink
Add polling for test
Browse files Browse the repository at this point in the history
  • Loading branch information
kharus committed Jan 13, 2025
1 parent f9e6828 commit aed9b47
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions natural4-server/tests/test_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from time import sleep
from time import sleep, time
from sanic import Sanic
from sanic_testing.reusable import ReusableClient
from sanic.application.constants import ServerStage
Expand Down Expand Up @@ -32,5 +32,14 @@ def test_post(app: Sanic, post_data):

sleep(15)

request, response_pdf = client.get(f'{workdir_url}/pdf/LATEST.pdf')
start_time = time()
while time() - start_time < 60:
print('Waiting for PDF...')
request, response_pdf = client.get(f'{workdir_url}/pdf/LATEST.pdf')
if response_pdf.status != 200:
sleep(5)
continue
else:
break

assert response_pdf.status == 200

0 comments on commit aed9b47

Please sign in to comment.