Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove implementation from test-dedicated hack
Jakub Draganek08b8cd975aed
diff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.pyindex 5e80aa7d0b..087a0cf9ce 100644--- a/saleor/payment/gateways/braintree/__init__.py+++ b/saleor/payment/gateways/braintree/__init__.py@@ -77,12 +77,6 @@ def extract_gateway_response(braintree_result) -> Dict:]bt_transaction = braintree_result.transaction- try:- customer_id = bt_transaction.customer_details.id- except:- # TODO: hack for legacy tests, remove when vcr data used everywhere- customer_id = None-if not bt_transaction:return {"errors": errors}return {@@ -90,7 +84,7 @@ def extract_gateway_response(braintree_result) -> Dict:"currency": bt_transaction.currency_iso_code,"amount": bt_transaction.amount, # Decimal type"credit_card": bt_transaction.credit_card,- "customer_id": customer_id,+ "customer_id": bt_transaction.customer_details.id,"errors": errors,}diff --git a/tests/gateway/test_braintree.py b/tests/gateway/test_braintree.pyindex 509362f695..61dd1d7038 100644--- a/tests/gateway/test_braintree.py+++ b/tests/gateway/test_braintree.py@@ -1,21 +1,14 @@-from decimal import Decimalimport os+from decimal import Decimalfrom unittest.mock import Mock, patch-import pytest-from django.core.exceptions import ImproperlyConfigured-from braintree.validation_error import ValidationError-from braintree.exceptions import NotFoundError-from braintree.errors import Errors+import pytestfrom braintree import Environment, ErrorResult, SuccessfulResult, Transaction+from braintree.errors import Errors+from braintree.exceptions import NotFoundError+from braintree.validation_error import ValidationError+from django.core.exceptions import ImproperlyConfigured-from saleor.payment.utils import create_payment_information-from saleor.payment.interface import GatewayConfig, TokenConfig-from saleor.payment.gateways.braintree.forms import BraintreePaymentForm-from saleor.payment.gateways.braintree.errors import (- DEFAULT_ERROR_MESSAGE,- BraintreeException,-)from saleor.payment.gateways.braintree import (TransactionKind,authorize,@@ -29,6 +22,13 @@ from saleor.payment.gateways.braintree import (refund,void,)+from saleor.payment.gateways.braintree.errors import (+ DEFAULT_ERROR_MESSAGE,+ BraintreeException,+)+from saleor.payment.gateways.braintree.forms import BraintreePaymentForm+from saleor.payment.interface import GatewayConfig, TokenConfig+from saleor.payment.utils import create_payment_informationINCORRECT_TOKEN_ERROR = ("Unable to process the transaction. Transaction's token is incorrect " "or expired."@@ -47,6 +47,7 @@ def braintree_success_response():amount=Decimal("80.00"),created_at="2018-10-20 18:34:22",credit_card="", # FIXME we should provide a proper CreditCard mock+ customer_details=Mock(id=None),additional_processor_response="",gateway_rejection_reason="",processor_response_code="1000",