Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix tests
Mateusz Grzybbd3b257f3738
diff --git a/saleor/payment/gateways/stripe/deprecated/tests/test_plugin.py b/saleor/payment/gateways/stripe/tests/test_plugin_deprecated.pysimilarity index 100%rename from saleor/payment/gateways/stripe/deprecated/tests/test_plugin.pyrename to saleor/payment/gateways/stripe/tests/test_plugin_deprecated.pydiff --git a/saleor/payment/gateways/stripe/tests/test_webhooks.py b/saleor/payment/gateways/stripe/tests/test_webhooks.pyindex 2fe3f4fd7e..de9c2b9f67 100644--- a/saleor/payment/gateways/stripe/tests/test_webhooks.py+++ b/saleor/payment/gateways/stripe/tests/test_webhooks.py@@ -33,11 +33,11 @@ from ..webhooks import (["metadata", "payment_method"],[({"key": "value"}, {"metadata": {"key": "value"}}),- ({}, {}),+ ({}, {"metadata": {}}),(None, {}),],)-def test_update_payment_method_metadata_from_payment_intent_with_payment_method(+def test_update_payment_method_metadata_from_payment_intent(metadata, payment_method) -> None:# given@@ -52,21 +52,6 @@ def test_update_payment_method_metadata_from_payment_intent_with_payment_method(assert payment_intent.payment_method == payment_method[email protected]("metadata", [{"key": "value"}, {}, None])-def test_update_payment_method_metadata_from_payment_intent_without_payment_method(- metadata,-) -> None:- # given- payment_intent = StripeObject(id="token", last_response={})- payment_intent["metadata"] = metadata-- # when- _update_payment_method_metadata_from_payment_intent(payment_intent)-- # then- assert payment_intent.get("payment_method") is None--@patch("saleor.payment.gateways.stripe.webhooks.complete_checkout", wraps=complete_checkout)diff --git a/saleor/payment/gateways/stripe/webhooks.py b/saleor/payment/gateways/stripe/webhooks.pyindex 88db22245b..f5595daeb0 100644--- a/saleor/payment/gateways/stripe/webhooks.py+++ b/saleor/payment/gateways/stripe/webhooks.py@@ -193,8 +193,11 @@ def _update_payment_method_metadata_from_payment_intent() -> None:payment_method = payment_intent.get("payment_method")metadata = payment_intent.get("metadata")- if payment_method is not None and metadata is not None:- payment_method["metadata"] = metadata+ if metadata is not None:+ if payment_method is not None:+ payment_method["metadata"] = metadata+ else:+ payment_intent["payment_method"] = {"metadata": metadata}def handle_authorized_payment_intent(@@ -306,8 +309,6 @@ def handle_successful_payment_intent(if changed_fields:payment.save(update_fields=changed_fields)- raise Exception(payment.metadata)-if payment.order_id:if payment.charge_status in [ChargeStatus.PENDING, ChargeStatus.NOT_CHARGED]:capture_transaction = _update_payment_with_new_transaction(