Skip to content

Commit

Permalink
Test if ocrmypdf is (un)/available
Browse files Browse the repository at this point in the history
  • Loading branch information
bosd committed Mar 30, 2023
1 parent 582ea54 commit f663826
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
except ImportError:
from io import StringIO # noqa: F401
import unittest
from unittest import mock

from invoice2data.main import extract_data
from invoice2data.input import pdftotext, tesseract, pdfminer_wrapper, pdfplumber
from invoice2data.input import pdftotext, tesseract, pdfminer_wrapper, pdfplumber, ocrmypdf
from invoice2data.output import to_csv, to_json, to_xml
from .common import get_sample_files

Expand Down Expand Up @@ -112,6 +113,18 @@ def test_tesseract_for_return(self):
else:
self.assertTrue(True)

def test_have_ocrmypdf_unavailable(self):
with mock.patch.dict('sys.modules', {'ocrmypdf': None}):
have = ocrmypdf.have_ocrmypdf()
print("ocrmypdf should not be available have is %s" % have)
self.assertFalse(have, "ocrmypdf is NOT installed")

def test_haveocrmypdf_available(self):
with mock.patch.dict('sys.modules', {'ocrmypdf': True}):
have = ocrmypdf.have_ocrmypdf()
print("ocrmypdf should be available have is %s" % have)
self.assertTrue(have, "ocrmypdf is installed")


if __name__ == '__main__':
unittest.main()

0 comments on commit f663826

Please sign in to comment.