Skip to content

Commit

Permalink
[FIX] account_statement_import_sheet_file: Fixed new tests errors
Browse files Browse the repository at this point in the history
  • Loading branch information
feg-adhoc committed Dec 30, 2024
1 parent 77b3d19 commit 5c5810e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -749,20 +749,28 @@ 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,
"statement_file": data,
"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)
Expand Down

0 comments on commit 5c5810e

Please sign in to comment.