Skip to content

Commit 6f1b901

Browse files
committed
Test also polling of invalid url
1 parent 78416a0 commit 6f1b901

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/test_convertapi.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
from unittest import mock
12
import convertapi
23
import os
34
import io
45
import tempfile
56
import time
67
import requests
8+
from requests.models import Response
79

810
from . import utils
911
from nose.tools import *
@@ -76,19 +78,29 @@ def test_user_info(self):
7678
user_info = convertapi.user()
7779
assert user_info['Active']
7880

81+
7982
class TestAsyncConvertapi(utils.TestCase):
8083
def setUp(self):
8184
convertapi.api_secret = os.environ['CONVERT_API_SECRET']
8285
convertapi.max_parallel_uploads = 10
8386

84-
def test_async_convert_file(self):
87+
def test_async_conversion_and_polling(self):
8588
convert_result = convertapi.async_convert('pdf', { 'File': 'examples/files/test.docx' })
8689
assert convert_result.response['JobId']
8790

8891
poll_result = get_poll_result(convert_result.response['JobId'])
8992
assert poll_result.save_files(tempfile.gettempdir())
9093
assert poll_result.conversion_cost > 0
9194

95+
def test_polling_of_invalid_job_id(self):
96+
fake_job_id = 'rwvd6vtq58eurfwv5zw5h2ci2pgno1pn'
97+
try:
98+
convertapi.async_poll(fake_job_id)
99+
except requests.exceptions.HTTPError:
100+
pass
101+
else:
102+
raise AssertionError
103+
92104

93105
def get_poll_result(job_id, retry_count=5):
94106
try:

0 commit comments

Comments
 (0)