From d0764b51a2d3ca4ea0e21b386f1d774aadd98e18 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 17 Oct 2022 15:05:49 +0000 Subject: [PATCH] [FIX] payment: tests requiring account_payment Skip the payment_asiapay test verifying the reference computation with an invoice when account_payment is not installed. Also add a dedicated helper, using the variable in payment already storing whether the account_payment module is installed. closes odoo/odoo#103449 X-original-commit: f1fd1c9e484025782079fc18c152269aa1723ed5 Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Victor Feyens (vfe) --- addons/payment/tests/common.py | 5 +++++ addons/payment_asiapay/tests/test_payment_transaction.py | 2 ++ addons/payment_ogone/tests/test_ogone.py | 3 +-- addons/payment_payulatam/tests/test_payulatam.py | 3 +-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/payment/tests/common.py b/addons/payment/tests/common.py index 9b9386010be..e298dca688b 100644 --- a/addons/payment/tests/common.py +++ b/addons/payment/tests/common.py @@ -228,3 +228,8 @@ class PaymentCommon(TransactionCase): self.fail(f"{func.__name__} should not raise error of class {exception_class.__name__}") except Exception: pass # Any exception whose class is not monitored is caught and ignored + + def _skip_if_account_payment_is_not_installed(self): + """ Skip current test if `account_payment` module is not installed. """ + if not self.account_payment_installed: + self.skipTest("account_payment module is not installed") diff --git a/addons/payment_asiapay/tests/test_payment_transaction.py b/addons/payment_asiapay/tests/test_payment_transaction.py index ccff3c62309..6abd076047e 100644 --- a/addons/payment_asiapay/tests/test_payment_transaction.py +++ b/addons/payment_asiapay/tests/test_payment_transaction.py @@ -25,6 +25,8 @@ class TestPaymentTransaction(AsiaPayCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior. def test_reference_is_computed_based_on_document_name(self): """ Test the computation of reference prefixes based on the provided invoice. """ + self._skip_if_account_payment_is_not_installed() + invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference( self.asiapay.code, invoice_ids=[Command.set([invoice.id])] diff --git a/addons/payment_ogone/tests/test_ogone.py b/addons/payment_ogone/tests/test_ogone.py index 85091fb092c..2c5b2700892 100644 --- a/addons/payment_ogone/tests/test_ogone.py +++ b/addons/payment_ogone/tests/test_ogone.py @@ -45,8 +45,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior def test_reference_is_computed_based_on_document_name(self): """ Test computation of reference prefixes based on the provided invoice. """ - if not self.env['ir.module.module']._get('account').state == 'installed': - self.skipTest('account module not installed') + self._skip_if_account_payment_is_not_installed() invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference( diff --git a/addons/payment_payulatam/tests/test_payulatam.py b/addons/payment_payulatam/tests/test_payulatam.py index 1acd7057a67..afc7be8ffcf 100644 --- a/addons/payment_payulatam/tests/test_payulatam.py +++ b/addons/payment_payulatam/tests/test_payulatam.py @@ -46,8 +46,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior def test_reference_is_computed_based_on_document_name(self): """ Test computation of reference prefixes based on the provided invoice. """ - if not self.env['ir.module.module']._get('account').state == 'installed': - self.skipTest('account module not installed') + self._skip_if_account_payment_is_not_installed() invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference(