From 07b73f1c9f4ab23a30b5fb21af28d7edeb6d6c49 Mon Sep 17 00:00:00 2001 From: bosd Date: Wed, 1 Nov 2023 22:12:48 +0100 Subject: [PATCH 1/2] base_business_document_import: Improve Coverage --- .../tests/test_business_document_import.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/base_business_document_import/tests/test_business_document_import.py b/base_business_document_import/tests/test_business_document_import.py index 90ddbedcf6..9581bad05d 100644 --- a/base_business_document_import/tests/test_business_document_import.py +++ b/base_business_document_import/tests/test_business_document_import.py @@ -9,7 +9,7 @@ from odoo.tests import tagged from odoo.tests.common import TransactionCase -logger = logging.getLogger(__name__) +_logger = logging.getLogger("odoo.tests.test_module_operations") @tagged("post_install", "-at_install") @@ -282,6 +282,8 @@ def test_match_shipping_partner(self): self.assertEqual(res, partner2) def test_match_currency(self): + currency_inv = self.env.ref("base.EUR") + currency_inv.active = True bdio = self.env["business.document.import"] currency_dict = {"xmlid": "base.USD"} res = bdio._match_currency(currency_dict, []) @@ -355,9 +357,8 @@ def test_match_product(self): try: bdio._match_product(product_dict, [], seller=False) raise_test = False - except Exception: - logger.info("Exception catched.") - + except Exception as e: + _logger.info(e) self.assertTrue(raise_test) def test_match_uom(self): From 58a923e0b28e6c8f72f62a19d101f9bbd20d1a8c Mon Sep 17 00:00:00 2001 From: bosd Date: Wed, 1 Nov 2023 22:45:56 +0100 Subject: [PATCH 2/2] base_business_document_import: test incoterm_match --- .../tests/test_business_document_import.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/base_business_document_import/tests/test_business_document_import.py b/base_business_document_import/tests/test_business_document_import.py index 9581bad05d..e631e2e68f 100644 --- a/base_business_document_import/tests/test_business_document_import.py +++ b/base_business_document_import/tests/test_business_document_import.py @@ -9,7 +9,7 @@ from odoo.tests import tagged from odoo.tests.common import TransactionCase -_logger = logging.getLogger("odoo.tests.test_module_operations") +logger = logging.getLogger(__name__) @tagged("post_install", "-at_install") @@ -357,8 +357,8 @@ def test_match_product(self): try: bdio._match_product(product_dict, [], seller=False) raise_test = False - except Exception as e: - _logger.info(e) + except Exception: + logger.info("Exception catched.") self.assertTrue(raise_test) def test_match_uom(self): @@ -481,3 +481,15 @@ def test_match_account_smaller_in(self): res = bdio._match_account({"code": "898999"}, chatter) self.assertEqual(acc, res) self.assertEqual(len(chatter), 1) + + def test_incoterm_match(self): + bdoo = self.env["business.document.import"] + incoterm_dict = {"code": "EXW"} + res = bdoo._match_incoterm(incoterm_dict, []) + self.assertEqual(res, self.env.ref("account.incoterm_EXW")) + incoterm_dict = {"code": "EXW WORKS"} + res = bdoo._match_incoterm(incoterm_dict, []) + self.assertEqual(res, self.env.ref("account.incoterm_EXW")) + incoterm_dict = {} + res = bdoo._match_incoterm(incoterm_dict, []) + self.assertFalse(res)