Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Deactivate dummy credit card by default
IKarbowiake25cf9b4a837
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.pyindex afa24fd185..3055f0c0bf 100644--- a/saleor/graphql/checkout/tests/test_checkout.py+++ b/saleor/graphql/checkout/tests/test_checkout.py@@ -647,16 +647,6 @@ def expected_dummy_gateway():}-def expected_dummy_credit_card_gateway():- return {- "id": "mirumee.payments.dummy_credit_card",- "name": "Dummy Credit Card",- "config": [{"field": "store_customer_card", "value": "false"}],- "currencies": ["USD"],- }--GET_CHECKOUT_PAYMENTS_QUERY = """query getCheckoutPayments($token: UUID!) {checkout(token: $token) {@@ -675,10 +665,7 @@ query getCheckoutPayments($token: UUID!) {def test_checkout_available_payment_gateways(- api_client,- checkout_with_item,- expected_dummy_gateway,- expected_dummy_credit_card_gateway,+ api_client, checkout_with_item, expected_dummy_gateway,):query = GET_CHECKOUT_PAYMENTS_QUERYvariables = {"token": str(checkout_with_item.token)}@@ -688,16 +675,11 @@ def test_checkout_available_payment_gateways(data = content["data"]["checkout"]assert data["availablePaymentGateways"] == [expected_dummy_gateway,- expected_dummy_credit_card_gateway,]def test_checkout_available_payment_gateways_currency_specified_USD(- api_client,- checkout_with_item,- expected_dummy_gateway,- expected_dummy_credit_card_gateway,- sample_gateway,+ api_client, checkout_with_item, expected_dummy_gateway, sample_gateway,):checkout_with_item.currency = "USD"checkout_with_item.save(update_fields=["currency"])@@ -711,7 +693,6 @@ def test_checkout_available_payment_gateways_currency_specified_USD(data = content["data"]["checkout"]assert {gateway["id"] for gateway in data["availablePaymentGateways"]} == {expected_dummy_gateway["id"],- expected_dummy_credit_card_gateway["id"],ActiveDummyPaymentGateway.PLUGIN_ID,}@@ -1904,7 +1885,12 @@ def test_checkout_complete_without_inventory_tracking(@pytest.mark.integration@pytest.mark.parametrize("token, error", list(TOKEN_VALIDATION_MAPPING.items()))-def test_checkout_complete_error_in_gateway_response(+@patch(+ "saleor.payment.gateways.dummy_credit_card.plugin."+ "DummyCreditCardGatewayPlugin.DEFAULT_ACTIVE",+ True,+)+def test_checkout_complete_error_in_gateway_response_for_dummy_credit_card(token,error,user_api_client,@@ -1914,7 +1900,6 @@ def test_checkout_complete_error_in_gateway_response(address,shipping_method,):-assert not gift_card.last_used_oncheckout = checkout_with_gift_carddiff --git a/saleor/graphql/payment/tests/test_payment.py b/saleor/graphql/payment/tests/test_payment.pyindex 444a4890f8..393bb9dd41 100644--- a/saleor/graphql/payment/tests/test_payment.py+++ b/saleor/graphql/payment/tests/test_payment.py@@ -1,4 +1,5 @@from decimal import Decimal+from unittest.mock import patchimport grapheneimport pytest@@ -498,6 +499,11 @@ def test_payment_capture_gateway_error(assert not txn.is_success+@patch(+ "saleor.payment.gateways.dummy_credit_card.plugin."+ "DummyCreditCardGatewayPlugin.DEFAULT_ACTIVE",+ True,+)def test_payment_capture_gateway_dummy_credit_card_error(staff_api_client, permission_manage_orders, payment_txn_preauth, monkeypatch):diff --git a/saleor/graphql/shop/tests/test_shop.py b/saleor/graphql/shop/tests/test_shop.pyindex d3d9e90c90..b031e862c2 100644--- a/saleor/graphql/shop/tests/test_shop.py+++ b/saleor/graphql/shop/tests/test_shop.py@@ -701,12 +701,10 @@ def test_query_available_payment_gateways(user_api_client, sample_gateway):data = content["data"]["shop"]["availablePaymentGateways"]assert {gateway["id"] for gateway in data} == {"mirumee.payments.dummy",- "mirumee.payments.dummy_credit_card","sampleDummy.active",}assert {gateway["name"] for gateway in data} == {"Dummy",- "Dummy Credit Card","SampleDummy",}@@ -720,12 +718,10 @@ def test_query_available_payment_gateways_specified_currency_USD(data = content["data"]["shop"]["availablePaymentGateways"]assert {gateway["id"] for gateway in data} == {"mirumee.payments.dummy",- "mirumee.payments.dummy_credit_card","sampleDummy.active",}assert {gateway["name"] for gateway in data} == {"Dummy",- "Dummy Credit Card","SampleDummy",}diff --git a/saleor/payment/gateways/dummy_credit_card/plugin.py b/saleor/payment/gateways/dummy_credit_card/plugin.pyindex 99b9f9806c..6821ef37c4 100644--- a/saleor/payment/gateways/dummy_credit_card/plugin.py+++ b/saleor/payment/gateways/dummy_credit_card/plugin.py@@ -35,7 +35,7 @@ def require_active_plugin(fn):class DummyCreditCardGatewayPlugin(BasePlugin):PLUGIN_ID = "mirumee.payments.dummy_credit_card"PLUGIN_NAME = GATEWAY_NAME- DEFAULT_ACTIVE = True+ DEFAULT_ACTIVE = FalseDEFAULT_CONFIGURATION = [{"name": "Store customers card", "value": False},{"name": "Automatic payment capture", "value": True},diff --git a/saleor/payment/gateways/dummy_credit_card/tests/test_dummy_credit_card.py b/saleor/payment/gateways/dummy_credit_card/tests/test_dummy_credit_card.pyindex 96cc020b8f..22aeb0bd63 100644--- a/saleor/payment/gateways/dummy_credit_card/tests/test_dummy_credit_card.py+++ b/saleor/payment/gateways/dummy_credit_card/tests/test_dummy_credit_card.py@@ -13,6 +13,7 @@ from .. import (refund,void,)+from ..plugin import DummyCreditCardGatewayPluginNO_LONGER_ACTIVE = "This payment is no longer active."CANNOT_BE_AUTHORIZED_AGAIN = "Charged transactions cannot be authorized again."@@ -25,6 +26,7 @@ CANNOT_CHARGE_MORE_THAN_UNCAPTURED = "Unable to charge more than un-captured amo@pytest.fixture(autouse=True)def setup_dummy_credit_card_gateway(settings):+ DummyCreditCardGatewayPlugin.DEFAULT_ACTIVE = Truesettings.PLUGINS = ["saleor.payment.gateways.dummy_credit_card.plugin.DummyCreditCardGatewayPlugin"]