-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_importers.py
35 lines (28 loc) · 1.3 KB
/
test_importers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import unittest
import importers.txt_importer as txt
import importers.doc_importer as doc
import importers.pdf_importer as pdf
import importers.img_importer as img
class TestImporters(unittest.TestCase):
def test_txt_importer(self):
expected = "this is\na multiple line\ntext file\n"
actual = txt.importer('test_files/small.txt')
self.assertEqual(actual, expected)
def test_docx_importer(self):
expected = "multiple lines in a\n\nword file with formatting.\n"
actual = doc.importer('test_files/small.docx')
self.assertEqual(actual, expected)
def test_odt_importer(self):
expected = "multiple lines in a\n\nlibreoffice file with formatting."
actual = doc.importer('test_files/small.odt')
self.assertEqual(actual.strip(), expected)
def test_pdf_importer(self):
expected = "multiple lines in a\npdf file with formatting.\n"
actual = pdf.importer('test_files/small.pdf')
self.assertEqual(actual, expected)
def test_png_importer(self):
expected = "This is a test PNG.\nHopefully, this text will be seen and interpreted properly.\nThat's the goal, anyway.\n"
actual = img.importer('test_files/test.png', 'png')
self.assertEqual(actual, expected)
if __name__ == '__main__':
unittest.main()