diff --git a/account_invoice_import_invoice2data/tests/test_invoice_import.py b/account_invoice_import_invoice2data/tests/test_invoice_import.py index 39ddb950e56..24efb35bc05 100644 --- a/account_invoice_import_invoice2data/tests/test_invoice_import.py +++ b/account_invoice_import_invoice2data/tests/test_invoice_import.py @@ -3,6 +3,8 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import base64 +import logging +from unittest import mock from odoo import fields from odoo.tests.common import TransactionCase @@ -27,6 +29,18 @@ def setUp(self): ) internet_product.supplier_taxes_id = [(6, 0, [frtax.id])] + def test_have_invoice2data_unavailable(self): + with mock.patch.dict("sys.modules", {"invoice2data": None}): + with self.assertLogs("", level="DEBUG") as cm: + logging.getLogger("").debug("Cannot import invoice2data") + self.assertEqual(cm.output, ["DEBUG:root:Cannot import invoice2data"]) + + def test_have_tesseract_unavailable(self): + with mock.patch.dict("sys.modules", {"tesseract": None}): + with self.assertLogs("", level="DEBUG") as cm: + logging.getLogger("").debug("Cannot import tesseract") + self.assertEqual(cm.output, ["DEBUG:root:Cannot import tesseract"]) + def test_import_free_invoice(self): filename = "invoice_free_fiber_201507.pdf" f = file_open("account_invoice_import_invoice2data/tests/pdf/" + filename, "rb")