File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 11import requests
22import convertapi
3+ import simplejson
34
45from io import BytesIO
56from .exceptions import *
@@ -50,7 +51,10 @@ def handle_response(self, r):
5051 except ValueError :
5152 raise e
5253
53- return r .json ()
54+ try :
55+ return r .json ()
56+ except simplejson .errors .JSONDecodeError as e :
57+ raise ApiError ({'message' : 'Conversion in progress' })
5458
5559 def url (self , path ):
5660 return "%s%s?Secret=%s" % (convertapi .base_uri , path , convertapi .api_secret )
Original file line number Diff line number Diff line change @@ -101,6 +101,15 @@ def test_polling_of_invalid_job_id(self):
101101 else :
102102 raise AssertionError
103103
104+ def test_polling_too_fast_and_getting_202_accepted (self ):
105+ convert_result = convertapi .async_convert ('pdf' , { 'File' : 'examples/files/test.docx' })
106+ try :
107+ convertapi .async_poll (convert_result .response ['JobId' ])
108+ except convertapi .ApiError :
109+ pass
110+ else :
111+ raise AssertionError
112+
104113
105114def get_poll_result (job_id , retry_count = 5 ):
106115 try :
You can’t perform that action at this time.
0 commit comments