[IMP] account_banking_sepa_direct_debit: test performance improvement

- Switch to setUpClass (if needed) for avoiding repeat the same setup for each test.
- Include context keys for avoiding mail operations overhead.
This commit is contained in:
josep-tecnativa
2023-10-16 12:22:10 +02:00
parent af410c38cc
commit 04b8eb64ff
2 changed files with 26 additions and 5 deletions

View File

@@ -33,11 +33,22 @@ class TestMandate(TransactionCase):
self.env["account.banking.mandate"]._sdd_mandate_set_state_to_expired()
self.assertEqual(self.mandate.state, "expired")
def setUp(self):
res = super().setUp()
self.partner = self.env.ref("base.res_partner_12")
bank_account = self.env.ref("account_payment_mode.res_partner_12_iban")
self.mandate = self.env["account.banking.mandate"].create(
@classmethod
def setUpClass(cls):
res = super().setUpClass()
cls.env = cls.env(
context=dict(
cls.env.context,
mail_create_nolog=True,
mail_create_nosubscribe=True,
mail_notrack=True,
no_reset_password=True,
tracking_disable=True,
)
)
cls.partner = cls.env.ref("base.res_partner_12")
bank_account = cls.env.ref("account_payment_mode.res_partner_12_iban")
cls.mandate = cls.env["account.banking.mandate"].create(
{
"partner_bank_id": bank_account.id,
"format": "sepa",

View File

@@ -15,6 +15,16 @@ class TestSDDBase(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(
context=dict(
cls.env.context,
mail_create_nolog=True,
mail_create_nosubscribe=True,
mail_notrack=True,
no_reset_password=True,
tracking_disable=True,
)
)
cls.company_B = cls.env["res.company"].create({"name": "Company B"})
user_type_payable = cls.env.ref("account.data_account_type_payable")
cls.account_payable_company_B = cls.env["account.account"].create(