[IMP] account_ebics - Add unit tests

Add 97 tests:

- account_ebics: order numbers, camt and CFONB split per account,
  journal lookup, duplicate statements, download and upload wizards,
  key initialisation (INI/HIA/HPB), passphrase change, admin orders.
- account_ebics_batch: scheduled import, import log, reprocess.
- account_ebics_payment_order / account_ebics_batch_payment: upload of
  the payment file and link to the payment document.
- account_ebics_statement_import_test (new, test-only, not to install
  in production): installs the OCA camt and CFONB parsers in CI and
  runs the end-to-end statement import.

The bank is simulated by patching ebics.xfer._setup_client, or the
fintech client classes for the key initialisation; keys, certificates
and the INI letter are real, created in a temporary directory.
This commit is contained in:
Jérémy Didderen committed 2026-10-27 23:14:34 +01:00
1 parent ed0bf5d6ae
commit a1fc381121
50 files changed
+2075 -5

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from odoo.exceptions import UserError
from odoo.tests import tagged
from .common import EbicsTestCommon
IBAN_FOR_COMPANY_TEST = "FR7630004000031234567890143"
@tagged("post_install", "-at_install")
class TestEbicsConfig(EbicsTestCommon):
def test_update_order_number(self):
cases = [
("A000", "A001"),
("A009", "A00A"),
("A00Z", "A010"),
("A0Z9", "A0ZA"),
("AZZZ", "B000"),
("ZZZY", "A000"),
# ZZZZ is accepted by the constraint, it must wrap as well
("ZZZZ", "A000"),
]
for current, expected in cases:
with self.subTest(current=current):
self.ebics_config._update_order_number(current)
self.assertEqual(self.ebics_config.order_number, expected)
def test_order_number_pattern(self):
for valid in ("A000", "B1Z9", "ZZZZ"):
with self.subTest(valid=valid):
self.ebics_config.order_number = valid
# No 5-character case: Char(size=4) truncates before the constraint runs.
for invalid in ("a001", "A01", "1000", "A-01"):
with self.subTest(invalid=invalid), self.assertRaises(UserError):
self.ebics_config.order_number = invalid
def test_unlink_confirmed_config_is_blocked(self):
with self.assertRaises(UserError):
self.ebics_config.unlink()
def test_unlink_draft_config(self):
self.ebics_userid.unlink()
self.ebics_config.set_to_draft()
self.ebics_config.unlink()
self.assertFalse(self.ebics_config.exists())
def test_company_ids_follow_journals(self):
journal = self._create_bank_journal("TCMP", IBAN_FOR_COMPANY_TEST)
self.assertEqual(self.ebics_config.company_ids, journal.company_id)
self.assertEqual(journal.ebics_config_id, self.ebics_config)