From 987b0d49f98a2e96a11320d2e7a32ee4ef243e37 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 9 May 2022 16:43:19 +0000 Subject: [PATCH] [IMP] payment: clean test utils All utilitary test methods will be private, to clearly separate test methods and utils. Task - 2848326 Part-of: odoo/odoo#90716 --- addons/payment/tests/common.py | 4 +- addons/payment/tests/http_common.py | 18 +++---- addons/payment/tests/test_account_payment.py | 22 ++++---- addons/payment/tests/test_flows.py | 50 +++++++++---------- .../payment/tests/test_multicompany_flows.py | 12 ++--- .../payment/tests/test_payment_transaction.py | 8 +-- addons/payment_adyen/tests/common.py | 4 +- addons/payment_adyen/tests/test_adyen.py | 42 ++++++++-------- addons/payment_alipay/tests/test_alipay.py | 18 +++---- .../payment_authorize/tests/test_authorize.py | 4 +- .../payment_buckaroo/tests/test_buckaroo.py | 16 +++--- .../tests/test_payment_transaction.py | 8 +-- .../tests/test_processing_flows.py | 12 ++--- addons/payment_mollie/tests/test_mollie.py | 4 +- addons/payment_ogone/tests/test_ogone.py | 12 ++--- addons/payment_paypal/tests/test_paypal.py | 12 ++--- .../payment_payulatam/tests/test_payulatam.py | 14 +++--- .../payment_payumoney/tests/test_payumoney.py | 8 +-- addons/payment_sips/tests/test_sips.py | 18 +++---- .../payment_stripe/tests/test_refund_flows.py | 4 +- addons/payment_stripe/tests/test_stripe.py | 12 ++--- addons/sale/tests/test_payment_flow.py | 16 +++--- 22 files changed, 159 insertions(+), 159 deletions(-) diff --git a/addons/payment/tests/common.py b/addons/payment/tests/common.py index 507f823e916..85b5831e4ab 100644 --- a/addons/payment/tests/common.py +++ b/addons/payment/tests/common.py @@ -175,7 +175,7 @@ class PaymentCommon(AccountTestInvoicingCommon): acquirer.state = 'test' return acquirer - def create_transaction(self, flow, sudo=True, **values): + def _create_transaction(self, flow, sudo=True, **values): default_values = { 'amount': self.amount, 'currency_id': self.currency.id, @@ -186,7 +186,7 @@ class PaymentCommon(AccountTestInvoicingCommon): } return self.env['payment.transaction'].sudo(sudo).create(dict(default_values, **values)) - def create_token(self, sudo=True, **values): + def _create_token(self, sudo=True, **values): default_values = { 'name': "XXXXXXXXXXXXXXX-2565 (TEST)", 'acquirer_id': self.acquirer.id, diff --git a/addons/payment/tests/http_common.py b/addons/payment/tests/http_common.py index 5c6f44d3e3f..7f21d114684 100644 --- a/addons/payment/tests/http_common.py +++ b/addons/payment/tests/http_common.py @@ -150,7 +150,7 @@ class PaymentHttpCommon(PaymentCommon, HttpCase): 'access_token': self._generate_test_access_token(partner.id, amount, currency.id), } - def portal_pay(self, **route_kwargs): + def _portal_pay(self, **route_kwargs): """/payment/pay txContext feedback NOTE: must be authenticated before calling method. @@ -160,8 +160,8 @@ class PaymentHttpCommon(PaymentCommon, HttpCase): url = self._build_url(uri) return self._make_http_get_request(url, route_kwargs) - def get_tx_checkout_context(self, **route_kwargs): - response = self.portal_pay(**route_kwargs) + def _get_tx_checkout_context(self, **route_kwargs): + response = self._portal_pay(**route_kwargs) self.assertEqual(response.status_code, 200) @@ -170,7 +170,7 @@ class PaymentHttpCommon(PaymentCommon, HttpCase): # /my/payment_method # ###################### - def portal_payment_method(self): + def _portal_payment_method(self): """/my/payment_method txContext feedback NOTE: must be authenticated before calling method @@ -180,8 +180,8 @@ class PaymentHttpCommon(PaymentCommon, HttpCase): url = self._build_url(uri) return self._make_http_get_request(url, {}) - def get_tx_manage_context(self): - response = self.portal_payment_method() + def _get_tx_manage_context(self): + response = self._portal_payment_method() self.assertEqual(response.status_code, 200) @@ -189,7 +189,7 @@ class PaymentHttpCommon(PaymentCommon, HttpCase): # payment/transaction # ####################### - def portal_transaction(self, **route_kwargs): + def _portal_transaction(self, **route_kwargs): """/payment/transaction feedback :return: The response to the json request @@ -201,8 +201,8 @@ class PaymentHttpCommon(PaymentCommon, HttpCase): return response - def get_processing_values(self, **route_kwargs): - response = self.portal_transaction(**route_kwargs) + def _get_processing_values(self, **route_kwargs): + response = self._portal_transaction(**route_kwargs) self.assertEqual(response.status_code, 200) diff --git a/addons/payment/tests/test_account_payment.py b/addons/payment/tests/test_account_payment.py index 31655228e4d..47dce31381c 100644 --- a/addons/payment/tests/test_account_payment.py +++ b/addons/payment/tests/test_account_payment.py @@ -12,7 +12,7 @@ class TestAccountPayment(PaymentCommon): def test_no_amount_available_for_refund_when_not_supported(self): self.acquirer.support_refund = False - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment self.assertEqual( tx.payment_id.amount_available_for_refund, @@ -23,7 +23,7 @@ class TestAccountPayment(PaymentCommon): def test_full_amount_available_for_refund_when_not_yet_refunded(self): self.acquirer.support_refund = 'full_only' # Should simply not be False - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment self.assertAlmostEqual( tx.payment_id.amount_available_for_refund, @@ -38,10 +38,10 @@ class TestAccountPayment(PaymentCommon): 'support_refund': 'full_only', # Should simply not be False 'support_manual_capture': True, # To create transaction in the 'authorized' state }) - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment for reference_index, state in enumerate(('draft', 'pending', 'authorized')): - self.create_transaction( + self._create_transaction( 'dummy', amount=-tx.amount, reference=f'R-{tx.reference}-{reference_index + 1}', @@ -59,9 +59,9 @@ class TestAccountPayment(PaymentCommon): def test_no_amount_available_for_refund_when_fully_refunded(self): self.acquirer.support_refund = 'full_only' # Should simply not be False - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment - self.create_transaction( + self._create_transaction( 'dummy', amount=-tx.amount, reference=f'R-{tx.reference}', @@ -78,9 +78,9 @@ class TestAccountPayment(PaymentCommon): def test_no_full_amount_available_for_refund_when_partially_refunded(self): self.acquirer.support_refund = 'partial' - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment - self.create_transaction( + self._create_transaction( 'dummy', amount=-(tx.amount / 10), reference=f'R-{tx.reference}', @@ -99,12 +99,12 @@ class TestAccountPayment(PaymentCommon): def test_refunds_count(self): self.acquirer.support_refund = 'full_only' # Should simply not be False - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment for reference_index, operation in enumerate( ('online_redirect', 'online_direct', 'online_token', 'validation', 'refund') ): - self.create_transaction( + self._create_transaction( 'dummy', reference=f'R-{tx.reference}-{reference_index + 1}', state='done', @@ -119,7 +119,7 @@ class TestAccountPayment(PaymentCommon): ) def test_action_post_calls_send_payment_request_only_once(self): - payment_token = self.create_token() + payment_token = self._create_token() payment_without_token = self.env['account.payment'].create({ 'payment_type': 'inbound', 'partner_type': 'customer', diff --git a/addons/payment/tests/test_flows.py b/addons/payment/tests/test_flows.py index 89d7649e5b5..35227a14b8d 100644 --- a/addons/payment/tests/test_flows.py +++ b/addons/payment/tests/test_flows.py @@ -26,7 +26,7 @@ class TestFlows(PaymentHttpCommon): route_values = self._prepare_pay_values() # /payment/pay - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) for key, val in tx_context.items(): if key in route_values: self.assertEqual(val, route_values[key]) @@ -50,10 +50,10 @@ class TestFlows(PaymentHttpCommon): }) if flow == 'token': - route_values['payment_option_id'] = self.create_token().id + route_values['payment_option_id'] = self._create_token().id with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**route_values) + processing_values = self._get_processing_values(**route_values) tx_sudo = self._get_tx(processing_values['reference']) # Tx values == given values @@ -156,7 +156,7 @@ class TestFlows(PaymentHttpCommon): validation_amount = self.acquirer._get_validation_amount() validation_currency = self.acquirer._get_validation_currency() - tx_context = self.get_tx_manage_context() + tx_context = self._get_tx_manage_context() expected_values = { 'partner_id': self.partner.id, 'access_token': self._generate_test_access_token(self.partner.id, None, None), @@ -179,7 +179,7 @@ class TestFlows(PaymentHttpCommon): 'is_validation': True, } with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**transaction_values) + processing_values = self._get_processing_values(**transaction_values) tx_sudo = self._get_tx(processing_values['reference']) # Tx values == given values @@ -223,14 +223,14 @@ class TestFlows(PaymentHttpCommon): route_values.pop('partner_id') # Pay without a partner specified --> redirection to login page - response = self.portal_pay(**route_values) + response = self._portal_pay(**route_values) url = urlparse(response.url) self.assertEqual(url.path, '/web/login') self.assertIn('redirect', parse_qs(url.query)) # Pay without a partner specified (but logged) --> pay with the partner of current user. self.authenticate(self.portal_user.login, self.portal_user.login) - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) self.assertEqual(tx_context['partner_id'], self.portal_partner.id) def test_pay_no_token(self): @@ -239,14 +239,14 @@ class TestFlows(PaymentHttpCommon): route_values.pop('access_token') # Pay without a partner specified --> redirection to login page - response = self.portal_pay(**route_values) + response = self._portal_pay(**route_values) url = urlparse(response.url) self.assertEqual(url.path, '/web/login') self.assertIn('redirect', parse_qs(url.query)) # Pay without a partner specified (but logged) --> pay with the partner of current user. self.authenticate(self.portal_user.login, self.portal_user.login) - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) self.assertEqual(tx_context['partner_id'], self.portal_partner.id) def test_pay_wrong_token(self): @@ -254,20 +254,20 @@ class TestFlows(PaymentHttpCommon): route_values['access_token'] = "abcde" # Pay with a wrong access token --> Not found (404) - response = self.portal_pay(**route_values) + response = self._portal_pay(**route_values) self.assertEqual(response.status_code, 404) def test_pay_wrong_currency(self): # Pay with a wrong currency --> Not found (404) self.currency = self.env['res.currency'].browse(self.env['res.currency'].search([], order='id desc', limit=1).id + 1000) route_values = self._prepare_pay_values() - response = self.portal_pay(**route_values) + response = self._portal_pay(**route_values) self.assertEqual(response.status_code, 404) # Pay with an inactive currency --> Not found (404) self.currency = self.env['res.currency'].search([('active', '=', False)], limit=1) route_values = self._prepare_pay_values() - response = self.portal_pay(**route_values) + response = self._portal_pay(**route_values) self.assertEqual(response.status_code, 404) def test_invoice_payment_flow(self): @@ -276,7 +276,7 @@ class TestFlows(PaymentHttpCommon): # Pay for this invoice (no impact even if amounts do not match) route_values = self._prepare_pay_values() route_values['invoice_id'] = self.invoice.id - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) self.assertEqual(tx_context['invoice_id'], self.invoice.id) # payment/transaction @@ -298,7 +298,7 @@ class TestFlows(PaymentHttpCommon): 'tokenization_requested': False, }) with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**route_values) + processing_values = self._get_processing_values(**route_values) tx_sudo = self._get_tx(processing_values['reference']) # Note: strangely, the check # self.assertEqual(tx_sudo.invoice_ids, invoice) @@ -317,7 +317,7 @@ class TestFlows(PaymentHttpCommon): }) # Transaction step with a wrong flow --> UserError with mute_logger('odoo.http'): - response = self.portal_transaction(**transaction_values) + response = self._portal_transaction(**transaction_values) self.assertIn( "odoo.exceptions.UserError: The payment should either be direct, with redirection, or made by a token.", response.text) @@ -328,7 +328,7 @@ class TestFlows(PaymentHttpCommon): # Transaction step with a wrong access token --> ValidationError with mute_logger('odoo.http'): - response = self.portal_transaction(**route_values) + response = self._portal_transaction(**route_values) self.assertIn( "odoo.exceptions.ValidationError: The access token is invalid.", response.text) @@ -339,13 +339,13 @@ class TestFlows(PaymentHttpCommon): # Log in as user from Company A self.authenticate(self.portal_user.login, self.portal_user.login) - token = self.create_token() + token = self._create_token() acquirer_b = self.acquirer.copy() acquirer_b.state = 'test' - token_b = self.create_token(acquirer_id=acquirer_b.id) + token_b = self._create_token(acquirer_id=acquirer_b.id) # User must see both enabled acquirers and tokens - manage_context = self.get_tx_manage_context() + manage_context = self._get_tx_manage_context() self.assertEqual(manage_context['partner_id'], self.partner.id) self.assertIn(self.acquirer.id, manage_context['acquirer_ids']) self.assertIn(acquirer_b.id, manage_context['acquirer_ids']) @@ -354,14 +354,14 @@ class TestFlows(PaymentHttpCommon): # Token of disabled acquirer(s) & disabled acquirers should not be shown self.acquirer.state = 'disabled' - manage_context = self.get_tx_manage_context() + manage_context = self._get_tx_manage_context() self.assertEqual(manage_context['partner_id'], self.partner.id) self.assertEqual(manage_context['acquirer_ids'], [acquirer_b.id]) self.assertEqual(manage_context['token_ids'], [token_b.id]) # Archived tokens must be hidden from the user token_b.active = False - manage_context = self.get_tx_manage_context() + manage_context = self._get_tx_manage_context() self.assertEqual(manage_context['partner_id'], self.partner.id) self.assertEqual(manage_context['acquirer_ids'], [acquirer_b.id]) self.assertEqual(manage_context['token_ids'], []) @@ -375,7 +375,7 @@ class TestFlows(PaymentHttpCommon): 'odoo.addons.payment.models.payment_transaction.PaymentTransaction' '._send_payment_request' ) as patched: - self.portal_transaction( + self._portal_transaction( **self._prepare_transaction_values(self.acquirer.id, 'direct') ) self.assertEqual(patched.call_count, 0) @@ -389,7 +389,7 @@ class TestFlows(PaymentHttpCommon): 'odoo.addons.payment.models.payment_transaction.PaymentTransaction' '._send_payment_request' ) as patched: - self.portal_transaction( + self._portal_transaction( **self._prepare_transaction_values(self.acquirer.id, 'redirect') ) self.assertEqual(patched.call_count, 0) @@ -403,8 +403,8 @@ class TestFlows(PaymentHttpCommon): 'odoo.addons.payment.models.payment_transaction.PaymentTransaction' '._send_payment_request' ) as patched: - self.portal_transaction( - **self._prepare_transaction_values(self.create_token().id, 'token') + self._portal_transaction( + **self._prepare_transaction_values(self._create_token().id, 'token') ) self.assertEqual(patched.call_count, 1) diff --git a/addons/payment/tests/test_multicompany_flows.py b/addons/payment/tests/test_multicompany_flows.py index d913d3c767c..54dc5bd87aa 100644 --- a/addons/payment/tests/test_multicompany_flows.py +++ b/addons/payment/tests/test_multicompany_flows.py @@ -48,7 +48,7 @@ class TestMultiCompanyFlows(PaymentHttpCommon): # Pay in company B route_values['company_id'] = self.company_b.id - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) for key, val in tx_context.items(): if key in route_values: if key == 'access_token': @@ -80,7 +80,7 @@ class TestMultiCompanyFlows(PaymentHttpCommon): 'tokenization_requested': False, }) with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**validation_values) + processing_values = self._get_processing_values(**validation_values) tx_sudo = self._get_tx(processing_values['reference']) # Tx values == given values @@ -103,12 +103,12 @@ class TestMultiCompanyFlows(PaymentHttpCommon): # Log in as user from Company A self.authenticate(self.portal_user.login, self.portal_user.login) - token = self.create_token() - token_company_b = self.create_token(acquirer_id=self.acquirer_company_b.id) + token = self._create_token() + token_company_b = self._create_token(acquirer_id=self.acquirer_company_b.id) # A partner should see all his tokens on the /my/payment_method route, # even if they are in other companies otherwise he won't ever see them. - manage_context = self.get_tx_manage_context() + manage_context = self._get_tx_manage_context() self.assertEqual(manage_context['partner_id'], self.partner.id) self.assertEqual(manage_context['acquirer_ids'], self.acquirer.ids) self.assertIn(token.id, manage_context['token_ids']) @@ -117,7 +117,7 @@ class TestMultiCompanyFlows(PaymentHttpCommon): def test_archive_token_logged_in_another_company(self): """User archives his token from another company.""" # get user's token from company A - token = self.create_token(partner_id=self.portal_partner.id) + token = self._create_token(partner_id=self.portal_partner.id) # assign user to another company company_b = self.env['res.company'].create({'name': 'Company B'}) diff --git a/addons/payment/tests/test_payment_transaction.py b/addons/payment/tests/test_payment_transaction.py index 2b2ba3d627b..702208131c2 100644 --- a/addons/payment/tests/test_payment_transaction.py +++ b/addons/payment/tests/test_payment_transaction.py @@ -10,12 +10,12 @@ class TestPaymentTransaction(PaymentCommon): def test_refunds_count(self): self.acquirer.support_refund = 'full_only' # Should simply not be False - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment for reference_index, operation in enumerate( ('online_redirect', 'online_direct', 'online_token', 'validation', 'refund') ): - self.create_transaction( + self._create_transaction( 'dummy', reference=f'R-{tx.reference}-{reference_index + 1}', state='done', @@ -31,7 +31,7 @@ class TestPaymentTransaction(PaymentCommon): def test_refund_transaction_values(self): self.acquirer.support_refund = 'partial' - tx = self.create_transaction('redirect', state='done') + tx = self._create_transaction('redirect', state='done') tx._reconcile_after_done() # Create the payment # Test the default values of a full refund transaction @@ -84,7 +84,7 @@ class TestPaymentTransaction(PaymentCommon): ) def test_no_payment_for_validations(self): - tx = self.create_transaction(flow='dummy', operation='validation') # Overwrite the flow + tx = self._create_transaction(flow='dummy', operation='validation') # Overwrite the flow tx._reconcile_after_done() payment_count = self.env['account.payment'].search_count( [('payment_transaction_id', '=', tx.id)] diff --git a/addons/payment_adyen/tests/common.py b/addons/payment_adyen/tests/common.py index 729c4086a9b..5503bbb2337 100644 --- a/addons/payment_adyen/tests/common.py +++ b/addons/payment_adyen/tests/common.py @@ -46,7 +46,7 @@ class AdyenCommon(PaymentCommon): ] } - def create_transaction(self, *args, acquirer_reference=None, **kwargs): + def _create_transaction(self, *args, acquirer_reference=None, **kwargs): if not acquirer_reference: acquirer_reference = self.psp_reference - return super().create_transaction(*args, acquirer_reference=acquirer_reference, **kwargs) + return super()._create_transaction(*args, acquirer_reference=acquirer_reference, **kwargs) diff --git a/addons/payment_adyen/tests/test_adyen.py b/addons/payment_adyen/tests/test_adyen.py index c4a1d33c0d4..881d225e36c 100644 --- a/addons/payment_adyen/tests/test_adyen.py +++ b/addons/payment_adyen/tests/test_adyen.py @@ -18,7 +18,7 @@ from odoo.addons.payment_adyen.tests.common import AdyenCommon class AdyenTest(AdyenCommon, PaymentHttpCommon): def test_processing_values(self): - tx = self.create_transaction(flow='direct') + tx = self._create_transaction(flow='direct') with mute_logger('odoo.addons.payment.models.payment_transaction'), \ patch( 'odoo.addons.payment.utils.generate_access_token', @@ -41,14 +41,14 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): def test_token_activation(self): """Activation of disabled adyen tokens is forbidden""" - token = self.create_token(active=False) + token = self._create_token(active=False) with self.assertRaises(UserError): token._handle_reactivation_request() @mute_logger('odoo.addons.payment_adyen.models.payment_transaction') def test_send_refund_request(self): self.acquirer.support_refund = 'full_only' # Should simply not be False - tx = self.create_transaction( + tx = self._create_transaction( 'redirect', state='done', acquirer_reference='source_reference' ) tx._reconcile_after_done() # Create the payment @@ -78,10 +78,10 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_get_tx_from_notification_data_returns_refund_tx(self): - source_tx = self.create_transaction( + source_tx = self._create_transaction( 'direct', state='done', acquirer_reference=self.original_reference ) - refund_tx = self.create_transaction( + refund_tx = self._create_transaction( 'direct', reference='RefundTx', acquirer_reference=self.psp_reference, @@ -103,7 +103,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): self.assertEqual(returned_tx, refund_tx, msg="The existing refund tx is the one returned") def test_get_tx_from_notification_data_creates_refund_tx_when_missing(self): - source_tx = self.create_transaction( + source_tx = self._create_transaction( 'direct', state='done', acquirer_reference=self.original_reference ) data = dict( @@ -124,7 +124,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_adyen.models.payment_transaction') def test_tx_state_after_send_capture_request(self): self.acquirer.capture_manually = True - tx = self.create_transaction('direct', state='authorized') + tx = self._create_transaction('direct', state='authorized') with patch( 'odoo.addons.payment_adyen.models.payment_acquirer.PaymentAcquirer._adyen_make_request', @@ -141,7 +141,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_adyen.models.payment_transaction') def test_tx_state_after_send_void_request(self): self.acquirer.capture_manually = True - tx = self.create_transaction('direct', state='authorized') + tx = self._create_transaction('direct', state='authorized') with patch( 'odoo.addons.payment_adyen.models.payment_acquirer.PaymentAcquirer._adyen_make_request', @@ -156,13 +156,13 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_webhook_notification_confirms_transaction(self): - tx = self.create_transaction('direct') + tx = self._create_transaction('direct') self._webhook_notification_flow(self.webhook_notification_batch_data) self.assertEqual(tx.state, 'done') def test_webhook_notification_authorizes_transaction(self): self.acquirer.capture_manually = True - tx = self.create_transaction('direct') + tx = self._create_transaction('direct') self._webhook_notification_flow(self.webhook_notification_batch_data) self.assertEqual( tx.state, @@ -173,7 +173,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): def test_webhook_notification_captures_transaction(self): self.acquirer.capture_manually = True - tx = self.create_transaction( + tx = self._create_transaction( 'direct', state='authorized', acquirer_reference=self.original_reference ) payload = dict(self.webhook_notification_batch_data, notificationItems=[{ @@ -186,7 +186,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_webhook_notification_cancels_transaction(self): - tx = self.create_transaction( + tx = self._create_transaction( 'direct', state='pending', acquirer_reference=self.original_reference ) payload = dict(self.webhook_notification_batch_data, notificationItems=[{ @@ -202,7 +202,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_webhook_notification_refunds_transaction(self): - source_tx = self.create_transaction( + source_tx = self._create_transaction( 'direct', state='done', acquirer_reference=self.original_reference ) payload = dict(self.webhook_notification_batch_data, notificationItems=[{ @@ -225,7 +225,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_failed_webhook_authorization_notification_leaves_transaction_in_draft(self): - tx = self.create_transaction('direct') + tx = self._create_transaction('direct') payload = dict(self.webhook_notification_batch_data, notificationItems=[ {'NotificationRequestItem': dict(self.webhook_notification_payload, success='false')} ]) @@ -237,7 +237,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_failed_webhook_capture_notification_leaves_transaction_authorized(self): - tx = self.create_transaction( + tx = self._create_transaction( 'direct', state='authorized', acquirer_reference=self.original_reference ) payload = dict(self.webhook_notification_batch_data, notificationItems=[{ @@ -252,7 +252,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_failed_webhook_cancellation_notification_leaves_transaction_authorized(self): - tx = self.create_transaction('direct', state='authorized') + tx = self._create_transaction('direct', state='authorized') payload = dict(self.webhook_notification_batch_data, notificationItems=[{ 'NotificationRequestItem': dict( self.webhook_notification_payload, eventCode='CANCELLATION', success='false' @@ -265,7 +265,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): ) def test_failed_webhook_refund_notification_sets_refund_transaction_in_error(self): - source_tx = self.create_transaction( + source_tx = self._create_transaction( 'direct', state='done', acquirer_reference=self.original_reference ) payload = dict(self.webhook_notification_batch_data, notificationItems=[{ @@ -305,7 +305,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_adyen.controllers.main') def test_webhook_notification_triggers_signature_check(self): """ Test that receiving a webhook notification triggers a signature check. """ - self.create_transaction('direct') + self._create_transaction('direct') url = self._build_url(AdyenController._webhook_url) with patch( 'odoo.addons.payment_adyen.controllers.main.AdyenController' @@ -319,7 +319,7 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): def test_accept_webhook_notification_with_valid_signature(self): """ Test the verification of a webhook notification with a valid signature. """ - tx = self.create_transaction('direct') + tx = self._create_transaction('direct') self._assert_does_not_raise( Forbidden, AdyenController._verify_notification_signature, @@ -331,14 +331,14 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon): def test_reject_webhook_notification_with_missing_signature(self): """ Test the verification of a webhook notification with a missing signature. """ payload = dict(self.webhook_notification_payload, additionalData={'hmacSignature': None}) - tx = self.create_transaction('direct') + tx = self._create_transaction('direct') self.assertRaises(Forbidden, AdyenController._verify_notification_signature, payload, tx) @mute_logger('odoo.addons.payment_adyen.controllers.main') def test_reject_webhook_notification_with_invalid_signature(self): """ Test the verification of a webhook notification with an invalid signature. """ payload = dict(self.webhook_notification_payload, additionalData={'hmacSignature': 'dummy'}) - tx = self.create_transaction('direct') + tx = self._create_transaction('direct') self.assertRaises(Forbidden, AdyenController._verify_notification_signature, payload, tx) def test_adyen_neutralize(self): diff --git a/addons/payment_alipay/tests/test_alipay.py b/addons/payment_alipay/tests/test_alipay.py index bb4a695f0c3..c2a89aa39b4 100644 --- a/addons/payment_alipay/tests/test_alipay.py +++ b/addons/payment_alipay/tests/test_alipay.py @@ -54,7 +54,7 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon): self._test_alipay_redirect_form() def _test_alipay_redirect_form(self): - tx = self.create_transaction(flow='redirect') # Only flow implemented + tx = self._create_transaction(flow='redirect') # Only flow implemented expected_values = { '_input_charset': 'utf-8', @@ -120,7 +120,7 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon): total_fee = self.currency.round(self.amount + transaction_fees) self.assertEqual(total_fee, 1118.2) - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') self.assertEqual(tx.fees, 7.09) with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx._get_processing_values() @@ -146,14 +146,14 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon): ) # Confirmed transaction - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.env['payment.transaction']._handle_notification_data('alipay', self.notification_data) self.assertEqual(tx.state, 'done') self.assertEqual(tx.acquirer_reference, self.notification_data['trade_no']) # Pending transaction self.reference = 'Test Transaction 2' - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict( self.notification_data, out_trade_no=self.reference, trade_status='TRADE_CLOSED' ) @@ -164,7 +164,7 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon): def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ self.acquirer.alipay_payment_method = 'standard_checkout' - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(AlipayController._webhook_url) with patch( 'odoo.addons.payment_alipay.controllers.main.AlipayController' @@ -180,7 +180,7 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon): def test_webhook_notification_triggers_origin_and_signature_checks(self): """ Test that receiving a webhook notification triggers origin and signature checks. """ self.acquirer.alipay_payment_method = 'standard_checkout' - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(AlipayController._webhook_url) with patch( 'odoo.addons.payment_alipay.controllers.main.AlipayController' @@ -198,7 +198,7 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon): def test_accept_notification_with_valid_signature(self): """ Test the verification of a notification with a valid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self._assert_does_not_raise( Forbidden, AlipayController._verify_notification_signature, self.notification_data, tx ) @@ -206,14 +206,14 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_alipay.controllers.main') def test_reject_notification_with_missing_signature(self): """ Test the verification of a notification with a missing signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict(self.notification_data, sign=None) self.assertRaises(Forbidden, AlipayController._verify_notification_signature, payload, tx) @mute_logger('odoo.addons.payment_alipay.controllers.main') def test_reject_notification_with_invalid_signature(self): """ Test the verification of a notification with an invalid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict(self.notification_data, sign='dummy') self.assertRaises(Forbidden, AlipayController._verify_notification_signature, payload, tx) diff --git a/addons/payment_authorize/tests/test_authorize.py b/addons/payment_authorize/tests/test_authorize.py index 9d76533082f..9b90542ee72 100644 --- a/addons/payment_authorize/tests/test_authorize.py +++ b/addons/payment_authorize/tests/test_authorize.py @@ -29,7 +29,7 @@ class AuthorizeTest(AuthorizeCommon): def test_processing_values(self): """Test custom 'access_token' processing_values for authorize acquirer.""" - tx = self.create_transaction(flow='direct') + tx = self._create_transaction(flow='direct') with mute_logger('odoo.addons.payment.models.payment_transaction'), \ patch( 'odoo.addons.payment.utils.generate_access_token', @@ -51,7 +51,7 @@ class AuthorizeTest(AuthorizeCommon): def test_token_activation(self): """Activation of disabled authorize tokens is forbidden""" - token = self.create_token(active=False) + token = self._create_token(active=False) with self.assertRaises(UserError): token._handle_reactivation_request() diff --git a/addons/payment_buckaroo/tests/test_buckaroo.py b/addons/payment_buckaroo/tests/test_buckaroo.py index 4c3e4f567e3..82eb48ecc75 100644 --- a/addons/payment_buckaroo/tests/test_buckaroo.py +++ b/addons/payment_buckaroo/tests/test_buckaroo.py @@ -33,7 +33,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): 'Brq_culture': 'en-US', } - tx_sudo = self.create_transaction(flow='redirect') + tx_sudo = self._create_transaction(flow='redirect') with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx_sudo._get_processing_values() form_info = self._extract_values_from_html_form(processing_values['redirect_form_html']) @@ -45,7 +45,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_buckaroo.models.payment_transaction') def test_feedback_processing(self): notification_data = BuckarooController._normalize_data_keys(self.sync_notification_data) - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') tx._handle_notification_data('buckaroo', notification_data) self.assertEqual(tx.state, 'done') self.assertEqual(tx.acquirer_reference, notification_data.get('brq_transactions')) @@ -54,7 +54,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): self.assertEqual(tx.acquirer_reference, notification_data.get('brq_transactions')) self.reference = 'Test Transaction 2' - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') notification_data = BuckarooController._normalize_data_keys(dict( self.sync_notification_data, brq_invoicenumber=self.reference, @@ -67,7 +67,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_buckaroo.controllers.main') def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(BuckarooController._webhook_url) with patch( 'odoo.addons.payment_buckaroo.controllers.main.BuckarooController' @@ -79,7 +79,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_buckaroo.controllers.main') def test_webhook_notification_triggers_signature_check(self): """ Test that receiving a webhook notification triggers a signature check. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(BuckarooController._return_url) with patch( 'odoo.addons.payment_buckaroo.controllers.main.BuckarooController' @@ -93,7 +93,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): def test_accept_notification_with_valid_signature(self): """ Test the verification of a notification with a valid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self._assert_does_not_raise( Forbidden, BuckarooController._verify_notification_signature, @@ -105,7 +105,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_buckaroo.controllers.main') def test_reject_notification_with_missing_signature(self): """ Test the verification of a notification with a missing signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.assertRaises( Forbidden, BuckarooController._verify_notification_signature, @@ -117,7 +117,7 @@ class BuckarooTest(BuckarooCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_buckaroo.controllers.main') def test_reject_notification_with_invalid_signature(self): """ Test the verification of a notification with an invalid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.assertRaises( Forbidden, BuckarooController._verify_notification_signature, diff --git a/addons/payment_flutterwave/tests/test_payment_transaction.py b/addons/payment_flutterwave/tests/test_payment_transaction.py index cb77d5ad527..1b47b5ea570 100644 --- a/addons/payment_flutterwave/tests/test_payment_transaction.py +++ b/addons/payment_flutterwave/tests/test_payment_transaction.py @@ -13,7 +13,7 @@ class TestPaymentTransaction(FlutterwaveCommon): def test_no_item_missing_from_rendering_values(self): """ Test that the rendered values are conform to the transaction fields. """ - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') with patch( 'odoo.addons.payment_flutterwave.models.payment_acquirer.PaymentAcquirer' '._flutterwave_make_request', return_value={'data': {'link': 'https://dummy.com'}} @@ -24,7 +24,7 @@ class TestPaymentTransaction(FlutterwaveCommon): @mute_logger('odoo.addons.payment.models.payment_transaction') def test_no_input_missing_from_redirect_form(self): """ Test that the `api_url` key is not omitted from the rendering values. """ - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') with patch( 'odoo.addons.payment_flutterwave.models.payment_transaction.PaymentTransaction' '._get_specific_rendering_values', return_value={'api_url': 'https://dummy.com'} @@ -38,7 +38,7 @@ class TestPaymentTransaction(FlutterwaveCommon): def test_processing_notification_data_confirms_transaction(self): """ Test that the transaction state is set to 'done' when the notification data indicate a successful payment. """ - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') with patch( 'odoo.addons.payment_flutterwave.models.payment_acquirer.PaymentAcquirer' '._flutterwave_make_request', return_value=self.verification_data @@ -49,7 +49,7 @@ class TestPaymentTransaction(FlutterwaveCommon): def test_processing_notification_data_tokenizes_transaction(self): """ Test that the transaction is tokenized when it was requested and the notification data include token data. """ - tx = self.create_transaction(flow='redirect', tokenize=True) + tx = self._create_transaction(flow='redirect', tokenize=True) with patch( 'odoo.addons.payment_flutterwave.models.payment_acquirer.PaymentAcquirer' '._flutterwave_make_request', return_value=self.verification_data diff --git a/addons/payment_flutterwave/tests/test_processing_flows.py b/addons/payment_flutterwave/tests/test_processing_flows.py index 46492f03753..4b1de91cc7c 100644 --- a/addons/payment_flutterwave/tests/test_processing_flows.py +++ b/addons/payment_flutterwave/tests/test_processing_flows.py @@ -18,7 +18,7 @@ class TestProcessingFlows(FlutterwaveCommon, PaymentHttpCommon): def test_redirect_notification_triggers_processing(self): """ Test that receiving a redirect notification triggers the processing of the notification data. """ - self.create_transaction(flow='redirect') + self._create_transaction(flow='redirect') url = self._build_url(FlutterwaveController._return_url) with patch( 'odoo.addons.payment.models.payment_transaction.PaymentTransaction' @@ -31,7 +31,7 @@ class TestProcessingFlows(FlutterwaveCommon, PaymentHttpCommon): def test_webhook_notification_triggers_processing(self): """ Test that receiving a valid webhook notification triggers the processing of the notification data. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(FlutterwaveController._webhook_url) with patch( 'odoo.addons.payment_flutterwave.controllers.main.FlutterwaveController.' @@ -46,7 +46,7 @@ class TestProcessingFlows(FlutterwaveCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_flutterwave.controllers.main') def test_webhook_notification_triggers_signature_check(self): """ Test that receiving a webhook notification triggers a signature check. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(FlutterwaveController._webhook_url) with patch( 'odoo.addons.payment_flutterwave.controllers.main.FlutterwaveController' @@ -60,7 +60,7 @@ class TestProcessingFlows(FlutterwaveCommon, PaymentHttpCommon): def test_accept_webhook_notification_with_valid_signature(self): """ Test the verification of a webhook notification with a valid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self._assert_does_not_raise( Forbidden, FlutterwaveController._verify_notification_signature, @@ -71,13 +71,13 @@ class TestProcessingFlows(FlutterwaveCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_flutterwave.controllers.main') def test_reject_notification_with_missing_signature(self): """ Test the verification of a notification with a missing signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.assertRaises(Forbidden, FlutterwaveController._verify_notification_signature, None, tx) @mute_logger('odoo.addons.payment_flutterwave.controllers.main') def test_reject_notification_with_invalid_signature(self): """ Test the verification of a notification with an invalid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.assertRaises( Forbidden, FlutterwaveController._verify_notification_signature, 'dummy', tx ) diff --git a/addons/payment_mollie/tests/test_mollie.py b/addons/payment_mollie/tests/test_mollie.py index 802c1d92fbd..424324678a5 100644 --- a/addons/payment_mollie/tests/test_mollie.py +++ b/addons/payment_mollie/tests/test_mollie.py @@ -14,7 +14,7 @@ from odoo.addons.payment_mollie.tests.common import MollieCommon class MollieTest(MollieCommon, PaymentHttpCommon): def test_payment_request_payload_values(self): - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') payload = tx._mollie_prepare_payment_request_payload() @@ -27,7 +27,7 @@ class MollieTest(MollieCommon, PaymentHttpCommon): ) def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(MollieController._webhook_url) with patch( 'odoo.addons.payment_mollie.models.payment_acquirer.PaymentAcquirer' diff --git a/addons/payment_ogone/tests/test_ogone.py b/addons/payment_ogone/tests/test_ogone.py index 8fbef1cdd5b..0b82f2fbffa 100644 --- a/addons/payment_ogone/tests/test_ogone.py +++ b/addons/payment_ogone/tests/test_ogone.py @@ -82,7 +82,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): expected_values, incoming=False ).upper() - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') self.assertEqual(tx.tokenize, False) with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx._get_processing_values() @@ -103,7 +103,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_ogone.controllers.main') def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(OgoneController._return_url) with patch( 'odoo.addons.payment_ogone.controllers.main.OgoneController' @@ -115,7 +115,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_ogone.controllers.main') def test_webhook_notification_triggers_signature_check(self): """ Test that receiving a webhook notification triggers a signature check. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(OgoneController._return_url) with patch( 'odoo.addons.payment_ogone.controllers.main.OgoneController' @@ -129,7 +129,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): def test_accept_notification_with_valid_signature(self): """ Test the verification of a notification with a valid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self._assert_does_not_raise( Forbidden, OgoneController._verify_notification_signature, @@ -141,7 +141,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_ogone.controllers.main') def test_reject_notification_with_missing_signature(self): """ Test the verification of a notification with a missing signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.assertRaises( Forbidden, OgoneController._verify_notification_signature, @@ -153,7 +153,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_ogone.controllers.main') def test_reject_notification_with_invalid_signature(self): """ Test the verification of a notification with an invalid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.assertRaises( Forbidden, OgoneController._verify_notification_signature, diff --git a/addons/payment_paypal/tests/test_paypal.py b/addons/payment_paypal/tests/test_paypal.py index a7ffef6aeaa..e7c1fa054b4 100644 --- a/addons/payment_paypal/tests/test_paypal.py +++ b/addons/payment_paypal/tests/test_paypal.py @@ -46,7 +46,7 @@ class PaypalTest(PaypalCommon, PaymentHttpCommon): return values def test_redirect_form_values(self): - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx._get_processing_values() @@ -70,7 +70,7 @@ class PaypalTest(PaypalCommon, PaymentHttpCommon): }) expected_values = self._get_expected_values() - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx._get_processing_values() form_info = self._extract_values_from_html_form(processing_values['redirect_form_html']) @@ -86,14 +86,14 @@ class PaypalTest(PaypalCommon, PaymentHttpCommon): self.env['payment.transaction']._handle_notification_data('paypal', self.notification_data) # Confirmed transaction - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.env['payment.transaction']._handle_notification_data('paypal', self.notification_data) self.assertEqual(tx.state, 'done') self.assertEqual(tx.acquirer_reference, self.notification_data['txn_id']) # Pending transaction self.reference = 'Test Transaction 2' - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict( self.notification_data, item_number=self.reference, @@ -131,7 +131,7 @@ class PaypalTest(PaypalCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_paypal.controllers.main') def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(PaypalController._webhook_url) with patch( 'odoo.addons.payment_paypal.controllers.main.PaypalController' @@ -143,7 +143,7 @@ class PaypalTest(PaypalCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_paypal.controllers.main') def test_webhook_notification_triggers_origin_check(self): """ Test that receiving a webhook notification triggers an origin check. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(PaypalController._webhook_url) with patch( 'odoo.addons.payment_paypal.controllers.main.PaypalController' diff --git a/addons/payment_payulatam/tests/test_payulatam.py b/addons/payment_payulatam/tests/test_payulatam.py index 7d4cfe1a7d5..7e1ebec7cbf 100644 --- a/addons/payment_payulatam/tests/test_payulatam.py +++ b/addons/payment_payulatam/tests/test_payulatam.py @@ -54,7 +54,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): def test_redirect_form_values(self): """ Test the values of the redirect form inputs. """ - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx._get_processing_values() @@ -133,7 +133,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): 'payulatam', payulatam_post_data ) - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') # Validate the transaction ('pending' state) self.env['payment.transaction']._handle_notification_data('payulatam', payulatam_post_data) @@ -155,7 +155,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_payulatam.controllers.main') def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(PayuLatamController._webhook_url) with patch( 'odoo.addons.payment_payulatam.controllers.main.PayuLatamController' @@ -167,7 +167,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_payulatam.controllers.main') def test_webhook_notification_triggers_signature_check(self): """ Test that receiving a webhook notification triggers a signature check. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(PayuLatamController._webhook_url) with patch( 'odoo.addons.payment_payulatam.controllers.main.PayuLatamController' @@ -181,7 +181,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): def test_accept_notification_with_valid_signature(self): """ Test the verification of a notification with a valid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = PayuLatamController._normalize_data_keys(self.async_notification_data) self._assert_does_not_raise( Forbidden, PayuLatamController._verify_notification_signature, payload, tx @@ -190,7 +190,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_payulatam.controllers.main') def test_reject_notification_with_missing_signature(self): """ Test the verification of a notification with a missing signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = PayuLatamController._normalize_data_keys( dict(self.async_notification_data, sign=None) ) @@ -201,7 +201,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_payulatam.controllers.main') def test_reject_notification_with_invalid_signature(self): """ Test the verification of a notification with an invalid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = PayuLatamController._normalize_data_keys( dict(self.async_notification_data, sign='dummy') ) diff --git a/addons/payment_payumoney/tests/test_payumoney.py b/addons/payment_payumoney/tests/test_payumoney.py index 715ec0b02a5..c2228b57b4d 100644 --- a/addons/payment_payumoney/tests/test_payumoney.py +++ b/addons/payment_payumoney/tests/test_payumoney.py @@ -30,7 +30,7 @@ class PayUMoneyTest(PayumoneyCommon, PaymentHttpCommon): self.assertNotIn(self.payumoney, acquirers) def test_redirect_form_values(self): - tx = self.create_transaction(flow='redirect') + tx = self._create_transaction(flow='redirect') with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx._get_processing_values() @@ -60,7 +60,7 @@ class PayUMoneyTest(PayumoneyCommon, PaymentHttpCommon): def test_accept_notification_with_valid_signature(self): """ Test the verification of a notification with a valid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self._assert_does_not_raise( Forbidden, PayUMoneyController._verify_notification_signature, @@ -71,7 +71,7 @@ class PayUMoneyTest(PayumoneyCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_payumoney.controllers.main') def test_reject_notification_with_missing_signature(self): """ Test the verification of a notification with a missing signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict(self.notification_data, hash=None) self.assertRaises( Forbidden, PayUMoneyController._verify_notification_signature, payload, tx @@ -80,7 +80,7 @@ class PayUMoneyTest(PayumoneyCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_payumoney.controllers.main') def test_reject_notification_with_invalid_signature(self): """ Test the verification of a notification with an invalid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict(self.notification_data, hash='dummy') self.assertRaises( Forbidden, PayUMoneyController._verify_notification_signature, payload, tx diff --git a/addons/payment_sips/tests/test_sips.py b/addons/payment_sips/tests/test_sips.py index 51a91ef1db0..73978ecffb5 100644 --- a/addons/payment_sips/tests/test_sips.py +++ b/addons/payment_sips/tests/test_sips.py @@ -40,7 +40,7 @@ class SipsTest(SipsCommon, PaymentHttpCommon): # freeze time for consistent singularize_prefix behavior during the test @freeze_time("2011-11-02 12:00:21") def test_reference(self): - tx = self.create_transaction(flow="redirect", reference="") + tx = self._create_transaction(flow="redirect", reference="") self.assertEqual(tx.reference, "tx20111102120021", "Payulatam: transaction reference wasn't correctly singularized.") @@ -48,7 +48,7 @@ class SipsTest(SipsCommon, PaymentHttpCommon): self.patch(self, 'base_url', lambda: 'http://127.0.0.1:8069') self.patch(type(self.env['base']), 'get_base_url', lambda _: 'http://127.0.0.1:8069') - tx = self.create_transaction(flow="redirect") + tx = self._create_transaction(flow="redirect") with mute_logger('odoo.addons.payment.models.payment_transaction'): processing_values = tx._get_processing_values() @@ -78,7 +78,7 @@ class SipsTest(SipsCommon, PaymentHttpCommon): ) # Confirmed transaction - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self.env['payment.transaction']._handle_notification_data('sips', self.notification_data) self.assertEqual(tx.state, 'done') self.assertEqual(tx.acquirer_reference, self.reference) @@ -86,7 +86,7 @@ class SipsTest(SipsCommon, PaymentHttpCommon): # Cancelled transaction old_reference = self.reference self.reference = 'Test Transaction 2' - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict( self.notification_data, Data=self.notification_data['Data'].replace(old_reference, self.reference) @@ -98,7 +98,7 @@ class SipsTest(SipsCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_sips.controllers.main') def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(SipsController._return_url) with patch( 'odoo.addons.payment_sips.controllers.main.SipsController' @@ -110,7 +110,7 @@ class SipsTest(SipsCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_sips.controllers.main') def test_webhook_notification_triggers_signature_check(self): """ Test that receiving a webhook notification triggers a signature check. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(SipsController._webhook_url) with patch( 'odoo.addons.payment_sips.controllers.main.SipsController' @@ -124,7 +124,7 @@ class SipsTest(SipsCommon, PaymentHttpCommon): def test_accept_notification_with_valid_signature(self): """ Test the verification of a notification with a valid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') self._assert_does_not_raise( Forbidden, SipsController._verify_notification_signature, self.notification_data, tx ) @@ -132,14 +132,14 @@ class SipsTest(SipsCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_sips.controllers.main') def test_reject_notification_with_missing_signature(self): """ Test the verification of a notification with a missing signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict(self.notification_data, Seal=None) self.assertRaises(Forbidden, SipsController._verify_notification_signature, payload, tx) @mute_logger('odoo.addons.payment_sips.controllers.main') def test_reject_notification_with_invalid_signature(self): """ Test the verification of a notification with an invalid signature. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') payload = dict(self.notification_data, Seal='dummy') self.assertRaises(Forbidden, SipsController._verify_notification_signature, payload, tx) diff --git a/addons/payment_stripe/tests/test_refund_flows.py b/addons/payment_stripe/tests/test_refund_flows.py index 02b6f620445..1424a1bcfce 100644 --- a/addons/payment_stripe/tests/test_refund_flows.py +++ b/addons/payment_stripe/tests/test_refund_flows.py @@ -17,7 +17,7 @@ class TestRefundFlows(StripeCommon, PaymentHttpCommon): def test_refund_id_is_set_as_acquirer_reference(self): """ Test that the id of the refund object is set as the acquirer reference of the refund transaction. """ - source_tx = self.create_transaction('redirect', state='done') + source_tx = self._create_transaction('redirect', state='done') with patch( 'odoo.addons.payment_stripe.models.payment_acquirer.PaymentAcquirer' '._stripe_make_request', return_value=self.refund_object @@ -35,7 +35,7 @@ class TestRefundFlows(StripeCommon, PaymentHttpCommon): def test_canceled_refund_webhook_notification_triggers_processing(self): """ Test that receiving a webhook notification for a refund cancellation (`charge.refund.updated` event) triggers the processing of the notification data. """ - source_tx = self.create_transaction('redirect', state='done') + source_tx = self._create_transaction('redirect', state='done') source_tx._create_refund_transaction( amount_to_refund=source_tx.amount, acquirer_reference=self.refund_object['id'] ) diff --git a/addons/payment_stripe/tests/test_stripe.py b/addons/payment_stripe/tests/test_stripe.py index a159a27fa01..1d38e29b11a 100644 --- a/addons/payment_stripe/tests/test_stripe.py +++ b/addons/payment_stripe/tests/test_stripe.py @@ -15,7 +15,7 @@ class StripeTest(StripeCommon, PaymentHttpCommon): def test_processing_values(self): dummy_session_id = 'cs_test_sbTG0yGwTszAqFUP8Ulecr1bUwEyQEo29M8taYvdP7UA6Qr37qX6uA6w' - tx = self.create_transaction(flow='redirect') # We don't really care what the flow is here. + tx = self._create_transaction(flow='redirect') # We don't really care what the flow is here. # Ensure no external API call is done, we only want to check the processing values logic def mock_stripe_create_checkout_session(self): @@ -33,7 +33,7 @@ class StripeTest(StripeCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_stripe.models.payment_transaction') def test_tx_state_after_send_capture_request(self): self.acquirer.capture_manually = True - tx = self.create_transaction('redirect', state='authorized') + tx = self._create_transaction('redirect', state='authorized') with patch( 'odoo.addons.payment_stripe.models.payment_acquirer.PaymentAcquirer' @@ -48,7 +48,7 @@ class StripeTest(StripeCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_stripe.models.payment_transaction') def test_tx_state_after_send_void_request(self): self.acquirer.capture_manually = True - tx = self.create_transaction('redirect', state='authorized') + tx = self._create_transaction('redirect', state='authorized') with patch( 'odoo.addons.payment_stripe.models.payment_acquirer.PaymentAcquirer' @@ -63,7 +63,7 @@ class StripeTest(StripeCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_stripe.controllers.main') def test_webhook_notification_confirms_transaction(self): """ Test the processing of a webhook notification. """ - tx = self.create_transaction('redirect') + tx = self._create_transaction('redirect') url = self._build_url(StripeController._webhook_url) with patch( 'odoo.addons.payment_stripe.controllers.main.StripeController' @@ -75,7 +75,7 @@ class StripeTest(StripeCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_stripe.controllers.main') def test_webhook_notification_tokenizes_payment_method(self): """ Test the processing of a webhook notification. """ - self.create_transaction('dummy', operation='validation', tokenize=True) + self._create_transaction('dummy', operation='validation', tokenize=True) url = self._build_url(StripeController._webhook_url) payment_method_response = { 'card': {'last4': '4242'}, @@ -101,7 +101,7 @@ class StripeTest(StripeCommon, PaymentHttpCommon): @mute_logger('odoo.addons.payment_stripe.controllers.main') def test_webhook_notification_triggers_signature_check(self): """ Test that receiving a webhook notification triggers a signature check. """ - self.create_transaction('redirect') + self._create_transaction('redirect') url = self._build_url(StripeController._webhook_url) with patch( 'odoo.addons.payment_stripe.controllers.main.StripeController' diff --git a/addons/sale/tests/test_payment_flow.py b/addons/sale/tests/test_payment_flow.py index d0f762f6e84..cf3e883e6f0 100644 --- a/addons/sale/tests/test_payment_flow.py +++ b/addons/sale/tests/test_payment_flow.py @@ -49,7 +49,7 @@ class TestSalePayment(PaymentHttpCommon): 'odoo.addons.payment.controllers.portal.PaymentPortal' '._compute_show_tokenize_input_mapping' ) as patched: - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) patched.assert_called_once_with(ANY, logged_in=ANY, sale_order_id=ANY) self.assertEqual(tx_context['currency_id'], self.order.currency_id.id) @@ -69,7 +69,7 @@ class TestSalePayment(PaymentHttpCommon): }) with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**route_values) + processing_values = self._get_processing_values(**route_values) tx_sudo = self._get_tx(processing_values['reference']) self.assertEqual(tx_sudo.sale_order_ids, self.order) @@ -94,7 +94,7 @@ class TestSalePayment(PaymentHttpCommon): route_values = self._prepare_pay_values() route_values['sale_order_id'] = self.order.id - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) self.assertEqual(tx_context['reference_prefix'], self.reference) self.assertEqual(tx_context['currency_id'], self.order.currency_id.id) @@ -111,7 +111,7 @@ class TestSalePayment(PaymentHttpCommon): 'landing_route': tx_context['landing_route'], }) with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**route_values) + processing_values = self._get_processing_values(**route_values) tx_sudo = self._get_tx(processing_values['reference']) self.assertEqual(tx_sudo.sale_order_ids, self.order) @@ -130,7 +130,7 @@ class TestSalePayment(PaymentHttpCommon): route_values = self._prepare_pay_values() route_values['sale_order_id'] = self.order.id - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) self.assertEqual(tx_context['reference_prefix'], self.reference) self.assertEqual(tx_context['currency_id'], self.order.currency_id.id) @@ -147,7 +147,7 @@ class TestSalePayment(PaymentHttpCommon): 'landing_route': tx_context['landing_route'], }) with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**route_values) + processing_values = self._get_processing_values(**route_values) tx2_sudo = self._get_tx(processing_values['reference']) self.assertEqual(tx2_sudo.sale_order_ids, self.order) @@ -175,7 +175,7 @@ class TestSalePayment(PaymentHttpCommon): route_values = self._prepare_pay_values() route_values['sale_order_id'] = self.order.id - tx_context = self.get_tx_checkout_context(**route_values) + tx_context = self._get_tx_checkout_context(**route_values) route_values.update({ 'flow': 'direct', @@ -186,7 +186,7 @@ class TestSalePayment(PaymentHttpCommon): 'landing_route': tx_context['landing_route'], }) with mute_logger('odoo.addons.payment.models.payment_transaction'): - processing_values = self.get_processing_values(**route_values) + processing_values = self._get_processing_values(**route_values) tx_sudo = self._get_tx(processing_values['reference']) tx_sudo._set_done()