[IMP] payment_test: support all additional features

After the payment apocalypse, `payment_test` was cleaned and stripped of
all useless parts. It was a very basic testing acquirer that allowed to
enter fake arbitrary payment details, choose whether they should be
tokenized, and then pay. It was intended to test the payment flow of
various applications (Sales, Subscriptions, Invoicing, ...) for a single
scenario: successful payments with immediate capture.

In order to extensively test an app's payment flow (explore other
scenarios), we need `payment_test` to have additional features.

Now, `payment_test` will allow profound testing of these features:
- separate authorization and capture
- customer fees computation
- tokenization
- refunds
- on the /pay page, users will be able to select the status of the
  payment
- on the payment transaction form view, users can change the status of
  a payment 'pending' to either succeed or fail
- on the payment token form view, users can change the state of future
  transactions made with that token

task-2512196

closes odoo/odoo#78083

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Co-authored-by: xlu-odoo <xlu@odoo.com>
This commit is contained in:
Valentin Chevalier
2022-07-01 19:37:10 +02:00
committed by Antoine Vandevenne (anv)
co-authored by xlu-odoo
parent 3262adf566
commit 2d81dffd23
18 changed files with 453 additions and 37 deletions
@@ -0,0 +1,24 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from unittest.mock import patch
from odoo.tests import tagged
from odoo.addons.payment_test.controllers.main import PaymentTestController
from odoo.addons.payment_test.tests.common import PaymentTestCommon
from odoo.addons.payment.tests.http_common import PaymentHttpCommon
@tagged('-at_install', 'post_install')
class TestProcessingFlows(PaymentTestCommon, PaymentHttpCommon):
def test_portal_payment_triggers_processing(self):
""" Test that paying from the frontend triggers the processing of the notification data. """
self._create_transaction(flow='direct')
url = self._build_url(PaymentTestController._simulation_url)
with patch(
'odoo.addons.payment.models.payment_transaction.PaymentTransaction'
'._handle_notification_data'
) as handle_notification_data_mock:
self._make_json_rpc_request(url, data=self.notification_data)
self.assertEqual(handle_notification_data_mock.call_count, 1)