Skip to content

Commit

Permalink
[IMP] account_invoice_import_invoice2data: test import errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bosd committed Oct 14, 2023
1 parent e107b8c commit f2c20d6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions account_invoice_import_invoice2data/tests/test_invoice_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit f2c20d6

Please sign in to comment.