Skip to content

Commit 8441db9

Browse files
committed
Add test for c.convert
1 parent 1517598 commit 8441db9

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

test/test_pdftables_api.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# limitations under the License.
1414

1515
import io
16+
import os
17+
18+
from tempfile import NamedTemporaryFile
19+
1620

1721
import requests_mock
1822

@@ -68,8 +72,25 @@ def test_successful_conversion(self):
6872

6973
pdf_fo = io.BytesIO(b'pdf content')
7074
c = Client('fake_key')
71-
s = c.dump(pdf_fo, 'csv')
72-
self.assertEqual(b'xlsx output', consume(s))
75+
76+
with NamedTemporaryFile(suffix="test.pdf") as tf:
77+
filename = tf.name
78+
79+
tf.write(b"Hello world")
80+
tf.file.close()
81+
82+
filename_out = filename.replace(".pdf", ".xlsx")
83+
84+
try:
85+
s = c.convert(filename, filename_out)
86+
87+
with open(filename_out) as fd:
88+
self.assertEqual(fd.read(), "xlsx output")
89+
finally:
90+
try:
91+
os.unlink(filename_out)
92+
except OSError:
93+
pass
7394

7495
def test_different_api_url(self):
7596
with requests_mock.mock() as m:

0 commit comments

Comments
 (0)