Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Assign tokens to variables in dummy payment
IKarbowiak9c7765bf5ed0
diff --git a/saleor/graphql/payment/tests/test_payment.py b/saleor/graphql/payment/tests/test_payment.pyindex 8951836cd1..6ee4d4c29c 100644--- a/saleor/graphql/payment/tests/test_payment.py+++ b/saleor/graphql/payment/tests/test_payment.py@@ -6,7 +6,7 @@ from django_countries.fields import Countryfrom ....checkout import calculationsfrom ....payment.error_codes import PaymentErrorCode-from ....payment.gateways.dummy import TOKEN_VALIDATION_MAPPING+from ....payment.gateways.dummy import TOKEN_EXPIRED, TOKEN_VALIDATION_MAPPINGfrom ....payment.interface import CreditCardInfo, CustomerSource, TokenConfigfrom ....payment.models import ChargeStatus, Payment, TransactionKindfrom ....payment.utils import fetch_customer_id, store_customer_id@@ -469,7 +469,8 @@ def test_payment_capture_with_payment_non_authorized_yet(def test_payment_capture_gateway_error(staff_api_client, permission_manage_orders, payment_txn_preauth, monkeypatch):- token, error = list(TOKEN_VALIDATION_MAPPING.items())[0]+ token = TOKEN_EXPIRED+ error = TOKEN_VALIDATION_MAPPING[token]payment = payment_txn_preauthtransaction = payment.transactions.last()transaction.token = tokendiff --git a/saleor/payment/gateways/dummy/__init__.py b/saleor/payment/gateways/dummy/__init__.pyindex f66679abf4..2e542c5d0b 100644--- a/saleor/payment/gateways/dummy/__init__.py+++ b/saleor/payment/gateways/dummy/__init__.py@@ -4,14 +4,21 @@ from typing import Optionalfrom ... import TransactionKindfrom ...interface import GatewayConfig, GatewayResponse, PaymentData-PREAUTHORIZED_TOKENS = ["4111111111111111", "4111111111111112"]+TOKEN_PREAUTHORIZE_SUCCESS = "4111111111111112"+TOKEN_PREAUTHORIZE_DECLINE = "4111111111111111"+TOKEN_EXPIRED = "4000000000000069"+TOKEN_INSUFFICIENT_FUNDS = "4000000000009995"+TOKEN_INCORRECT_CVV = "4000000000000127"+TOKEN_DECLINE = "4000000000000002"++PREAUTHORIZED_TOKENS = [TOKEN_PREAUTHORIZE_DECLINE, TOKEN_PREAUTHORIZE_SUCCESS]TOKEN_VALIDATION_MAPPING = {- "4000000000000069": "Card expired",- "4000000000009995": "Insufficient funds",- "4000000000000127": "Incorrect csv",- "4000000000000002": "Card declined",- "4111111111111111": "Card declined",+ TOKEN_EXPIRED: "Card expired",+ TOKEN_INSUFFICIENT_FUNDS: "Insufficient funds",+ TOKEN_INCORRECT_CVV: "Incorrect cvv",+ TOKEN_DECLINE: "Card declined",+ TOKEN_PREAUTHORIZE_DECLINE: "Card declined",}diff --git a/saleor/payment/gateways/dummy/tests/test_dummy.py b/saleor/payment/gateways/dummy/tests/test_dummy.pyindex 1f4776812d..9ff39bf780 100644--- a/saleor/payment/gateways/dummy/tests/test_dummy.py+++ b/saleor/payment/gateways/dummy/tests/test_dummy.py@@ -5,6 +5,7 @@ import pytestfrom .... import ChargeStatus, PaymentError, TransactionKind, gatewayfrom .. import (PREAUTHORIZED_TOKENS,+ TOKEN_EXPIRED,TOKEN_VALIDATION_MAPPING,authorize,capture,@@ -375,7 +376,7 @@ def test_process_payment_pre_authorized_and_capture_error(payment_dummy, dummy_gateway_config, monkeypatch):# given- token = PREAUTHORIZED_TOKENS[0]+ token = TOKEN_EXPIREDdummy_gateway_config.auto_capture = Truemonkeypatch.setattr("saleor.payment.gateways.dummy.plugin.DummyGatewayPlugin._get_gateway_config",