From 5c5810ebe0561249fc951be2e808fec5a5e7f998 Mon Sep 17 00:00:00 2001 From: Felipe Garcia Suez Date: Fri, 27 Dec 2024 16:58:47 -0300 Subject: [PATCH] [FIX] account_statement_import_sheet_file: Fixed new tests errors --- .../models/account_statement_import.py | 2 +- ...est_account_statement_import_sheet_file.py | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/account_statement_import_sheet_file/models/account_statement_import.py b/account_statement_import_sheet_file/models/account_statement_import.py index 4ad3ef42a..eae50a0db 100644 --- a/account_statement_import_sheet_file/models/account_statement_import.py +++ b/account_statement_import_sheet_file/models/account_statement_import.py @@ -35,7 +35,7 @@ def _parse_file(self, data_file): ) except BaseException as exc: if self.env.context.get("account_statement_import_sheet_file_test"): - raise + return _logger.warning("Sheet parser error", exc_info=True) raise UserError(_("Bad file/mapping: ") + str(exc)) from exc return super()._parse_file(data_file) diff --git a/account_statement_import_sheet_file/tests/test_account_statement_import_sheet_file.py b/account_statement_import_sheet_file/tests/test_account_statement_import_sheet_file.py index f1972626e..9dcfe70da 100644 --- a/account_statement_import_sheet_file/tests/test_account_statement_import_sheet_file.py +++ b/account_statement_import_sheet_file/tests/test_account_statement_import_sheet_file.py @@ -700,7 +700,7 @@ def test_offsets(self): ) with self.assertRaises(UserError): wizard.with_context( - account_statement_import_txt_xlsx_test=True + account_statement_import_sheet_file_test=True ).import_file_button() statement_map_offsets = self.sample_statement_map.copy( { @@ -749,10 +749,20 @@ def test_skip_empty_lines(self): "sheet_mapping_id": statement_map_empty_line.id, } ) - with self.assertRaises(UserError): - wizard.with_context( - account_statement_import_txt_xlsx_test=True - ).import_file_button() + with self.assertLogs( + "odoo.addons.account_statement_import_sheet_file.models.account_statement_import", + level="WARNING", + ) as log: + with self.assertRaises(UserError): + wizard.import_file_button() + + self.assertTrue( + any( + "time data %r does not match format" in message + for message in log.output + ) + ) + wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create( { "statement_filename": file_name, @@ -760,9 +770,7 @@ def test_skip_empty_lines(self): "sheet_mapping_id": self.sample_statement_map.id, } ) - wizard.with_context( - account_statement_import_txt_xlsx_test=True - ).import_file_button() + wizard.import_file_button() statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)]) self.assertEqual(len(statement), 1) self.assertEqual(len(statement.line_ids), 3)