Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Rename all plugin_manager/plugins parameter to manager for name consistency

IKarbowiak28799575c518
diff --git a/saleor/checkout/complete_checkout.py b/saleor/checkout/complete_checkout.py
index c7bfa9e82c..6217f54b00 100644
--- a/saleor/checkout/complete_checkout.py
+++ b/saleor/checkout/complete_checkout.py
@@ -514,17 +514,17 @@ def _process_payment(
store_source: bool,
payment_data: Optional[dict],
order_data: dict,
- plugin_manager: "PluginsManager",
+ manager: "PluginsManager",
) -> Transaction:
"""Process the payment assigned to checkout."""
try:
if payment.to_confirm:
- txn = gateway.confirm(payment, plugin_manager, additional_data=payment_data)
+ txn = gateway.confirm(payment, manager, additional_data=payment_data)
else:
txn = gateway.process_payment(
payment=payment,
token=payment.token,
- plugin_manager=plugin_manager,
+ manager=manager,
store_source=store_source,
additional_data=payment_data,
)
@@ -578,7 +578,7 @@ def complete_checkout(
store_source=store_source,
payment_data=payment_data,
order_data=order_data,
- plugin_manager=manager,
+ manager=manager,
)
if txn.customer_id and user.is_authenticated:
diff --git a/saleor/graphql/product/types/channels.py b/saleor/graphql/product/types/channels.py
index b8f8eb3cc3..78e0e7d044 100644
--- a/saleor/graphql/product/types/channels.py
+++ b/saleor/graphql/product/types/channels.py
@@ -178,7 +178,7 @@ class ProductChannelListing(CountableDjangoObjectType):
collections=collections,
discounts=discounts,
channel=channel,
- plugins=context.plugins,
+ manager=context.plugins,
country=Country(country_code),
local_currency=get_currency_for_country(
country_code
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index 651a485758..18f734657b 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -695,7 +695,7 @@ class Product(ChannelContextTypeWithMetadata, CountableDjangoObjectType):
collections=collections,
discounts=discounts,
channel=channel,
- plugins=context.plugins,
+ manager=context.plugins,
country=Country(country_code),
local_currency=get_currency_for_country(
country_code
diff --git a/saleor/order/actions.py b/saleor/order/actions.py
index f42c81955f..7ab44e69cf 100644
--- a/saleor/order/actions.py
+++ b/saleor/order/actions.py
@@ -704,7 +704,7 @@ def create_refund_fulfillment(
payment,
order_lines_to_refund: List[OrderLineData],
fulfillment_lines_to_refund: List[FulfillmentLineData],
- plugin_manager: "PluginsManager",
+ manager: "PluginsManager",
amount=None,
refund_shipping_costs=False,
):
@@ -727,7 +727,7 @@ def create_refund_fulfillment(
fulfillment_lines_to_refund=fulfillment_lines_to_refund,
amount=amount,
refund_shipping_costs=refund_shipping_costs,
- manager=plugin_manager,
+ manager=manager,
)
with transaction.atomic():
@@ -1007,7 +1007,7 @@ def create_fulfillments_for_returned_products(
payment: Optional[Payment],
order_lines: List[OrderLineData],
fulfillment_lines: List[FulfillmentLineData],
- plugin_manager: "PluginsManager",
+ manager: "PluginsManager",
refund: bool = False,
amount: Optional[Decimal] = None,
refund_shipping_costs=False,
@@ -1044,7 +1044,7 @@ def create_fulfillments_for_returned_products(
fulfillment_lines_to_refund=return_fulfillment_lines,
amount=amount,
refund_shipping_costs=refund_shipping_costs,
- manager=plugin_manager,
+ manager=manager,
)
with transaction.atomic():
@@ -1064,7 +1064,7 @@ def create_fulfillments_for_returned_products(
order=order,
order_lines=return_order_lines,
fulfillment_lines=return_fulfillment_lines,
- manager=plugin_manager,
+ manager=manager,
refund=refund,
)
Fulfillment.objects.filter(order=order, lines=None).delete()
diff --git a/saleor/order/tests/test_order_actions_create_fulfillments_for_returned_products.py b/saleor/order/tests/test_order_actions_create_fulfillments_for_returned_products.py
index 29327cf608..2a48b2053a 100644
--- a/saleor/order/tests/test_order_actions_create_fulfillments_for_returned_products.py
+++ b/saleor/order/tests/test_order_actions_create_fulfillments_for_returned_products.py
@@ -37,7 +37,7 @@ def test_create_return_fulfillment_only_order_lines(
for line in order_lines_to_return
],
fulfillment_lines=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillment, replaced_fulfillment, replace_order = response
@@ -103,7 +103,7 @@ def test_create_return_fulfillment_only_order_lines_with_refund(
for line in order_lines_to_return
],
fulfillment_lines=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund=True,
)
returned_fulfillment, replaced_fulfillment, replace_order = response
@@ -158,7 +158,7 @@ def test_create_return_fulfillment_only_order_lines_included_shipping_costs(
for line in order_lines_to_return
],
fulfillment_lines=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund=True,
refund_shipping_costs=True,
)
@@ -221,7 +221,7 @@ def test_create_return_fulfillment_only_order_lines_with_replace_request(
payment=payment,
order_lines=order_lines_data,
fulfillment_lines=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillment, replaced_fulfillment, replace_order = response
@@ -324,7 +324,7 @@ def test_create_return_fulfillment_multiple_order_line_returns(
OrderLineData(line=line, quantity=1) for line in order_lines_to_return
],
fulfillment_lines=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund=True,
)
@@ -361,7 +361,7 @@ def test_create_return_fulfillment_only_fulfillment_lines(
FulfillmentLineData(line=line, quantity=2, replace=False)
for line in fulfillment_lines
],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillment, replaced_fulfillment, replace_order = response
@@ -407,7 +407,7 @@ def test_create_return_fulfillment_only_fulfillment_lines_replace_order(
payment=payment,
order_lines=[],
fulfillment_lines=fulfillment_lines_to_return,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillment, replaced_fulfillment, replace_order = response
@@ -499,7 +499,7 @@ def test_create_return_fulfillment_multiple_fulfillment_lines_returns(
FulfillmentLineData(line=line, quantity=1)
for line in fulfillment_lines_to_return
],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund=True,
)
@@ -572,7 +572,7 @@ def test_create_return_fulfillment_multiple_lines_returns(
FulfillmentLineData(line=line, quantity=1)
for line in fulfillment_lines_to_return
],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund=True,
)
@@ -654,7 +654,7 @@ def test_create_return_fulfillment_multiple_lines_without_refund(
payment=payment,
order_lines=[OrderLineData(line=order_line, quantity=1)],
fulfillment_lines=fulfillment_lines_to_process,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund=False,
)
@@ -743,7 +743,7 @@ def test_create_return_fulfillment_with_lines_already_refunded(
payment=payment,
order_lines=[],
fulfillment_lines=fulfillment_lines_to_process,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund=True,
)
diff --git a/saleor/order/tests/test_order_actions_refund_products.py b/saleor/order/tests/test_order_actions_refund_products.py
index 27cc7e3e4b..280774082d 100644
--- a/saleor/order/tests/test_order_actions_refund_products.py
+++ b/saleor/order/tests/test_order_actions_refund_products.py
@@ -39,7 +39,7 @@ def test_create_refund_fulfillment_only_order_lines(
OrderLineData(line=line, quantity=2) for line in order_lines_to_refund
],
fulfillment_lines_to_refund=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillment_lines = returned_fulfillemnt.lines.all()
@@ -90,7 +90,7 @@ def test_create_refund_fulfillment_multiple_order_line_refunds(
OrderLineData(line=line, quantity=1) for line in order_lines_to_refund
],
fulfillment_lines_to_refund=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillemnt = Fulfillment.objects.get(
@@ -132,7 +132,7 @@ def test_create_refund_fulfillment_included_shipping_costs(
OrderLineData(line=line, quantity=2) for line in order_lines_to_refund
],
fulfillment_lines_to_refund=[],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
refund_shipping_costs=True,
)
returned_fulfillment_lines = returned_fulfillemnt.lines.all()
@@ -171,7 +171,7 @@ def test_create_refund_fulfillment_only_fulfillment_lines(
FulfillmentLineData(line=line, quantity=2)
for line in fulfillment_lines_to_refund
],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillment_lines = returned_fulfillemnt.lines.all()
assert returned_fulfillemnt.status == FulfillmentStatus.REFUNDED
@@ -212,7 +212,7 @@ def test_create_refund_fulfillment_multiple_fulfillment_lines_refunds(
FulfillmentLineData(line=line, quantity=1)
for line in fulfillment_lines_to_refund
],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillemnt = Fulfillment.objects.get(
@@ -255,7 +255,7 @@ def test_create_refund_fulfillment_custom_amount(
FulfillmentLineData(line=line, quantity=2)
for line in fulfillment_lines_to_refund
],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=amount,
)
@@ -324,7 +324,7 @@ def test_create_refund_fulfillment_multiple_refunds(
FulfillmentLineData(line=line, quantity=1)
for line in fulfillment_lines_to_refund
],
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
returned_fulfillemnt = Fulfillment.objects.get(
diff --git a/saleor/payment/gateway.py b/saleor/payment/gateway.py
index e03cdaab7d..687a06e4c0 100644
--- a/saleor/payment/gateway.py
+++ b/saleor/payment/gateway.py
@@ -74,7 +74,7 @@ def with_locked_payment(fn: Callable) -> Callable:
def process_payment(
payment: Payment,
token: str,
- plugin_manager: "PluginsManager",
+ manager: "PluginsManager",
store_source: bool = False,
additional_data: Optional[dict] = None,
) -> Transaction:
@@ -86,7 +86,7 @@ def process_payment(
)
response, error = _fetch_gateway_response(
- plugin_manager.process_payment, payment.gateway, payment_data
+ manager.process_payment, payment.gateway, payment_data
)
action_required = response is not None and response.action_required
if response and response.payment_method_info:
@@ -108,7 +108,7 @@ def process_payment(
def authorize(
payment: Payment,
token: str,
- plugin_manager: "PluginsManager",
+ manager: "PluginsManager",
store_source: bool = False,
) -> Transaction:
clean_authorize(payment)
@@ -116,7 +116,7 @@ def authorize(
payment=payment, payment_token=token, store_source=store_source
)
response, error = _fetch_gateway_response(
- plugin_manager.authorize_payment, payment.gateway, payment_data
+ manager.authorize_payment, payment.gateway, payment_data
)
if response and response.payment_method_info:
update_payment_method_details(payment, response)
@@ -136,7 +136,7 @@ def authorize(
@payment_postprocess
def capture(
payment: Payment,
- plugin_manager: "PluginsManager",
+ manager: "PluginsManager",
amount: Decimal = None,
store_source: bool = False,
) -> Transaction:
@@ -148,7 +148,7 @@ def capture(
payment=payment, payment_token=token, amount=amount, store_source=store_source
)
response, error = _fetch_gateway_response(
- plugin_manager.capture_payment, payment.gateway, payment_data
+ manager.capture_payment, payment.gateway, payment_data
)
if response and response.payment_method_info:
update_payment_method_details(payment, response)
@@ -166,7 +166,7 @@ def capture(
@with_locked_payment
@payment_postprocess
def refund(
- payment: Payment, plugin_manager: "PluginsManager", amount: Decimal = None
+ payment: Payment, manager: "PluginsManager", amount: Decimal = None
) -> Transaction:
if amount is None:
amount = payment.captured_amount
@@ -190,7 +190,7 @@ def refund(
)
response, error = _fetch_gateway_response(
- plugin_manager.refund_payment, payment.gateway, payment_data
+ manager.refund_payment, payment.gateway, payment_data
)
return get_already_processed_transaction_or_create_new_transaction(
payment=payment,
@@ -205,11 +205,11 @@ def refund(
@require_active_payment
@with_locked_payment
@payment_postprocess
-def void(payment: Payment, plugin_manager: "PluginsManager") -> Transaction:
+def void(payment: Payment, manager: "PluginsManager") -> Transaction:
token = _get_past_transaction_token(payment, TransactionKind.AUTH)
payment_data = create_payment_information(payment=payment, payment_token=token)
response, error = _fetch_gateway_response(
- plugin_manager.void_payment, payment.gateway, payment_data
+ manager.void_payment, payment.gateway, payment_data
)
return get_already_processed_transaction_or_create_new_transaction(
payment=payment,
@@ -226,7 +226,7 @@ def void(payment: Payment, plugin_manager: "PluginsManager") -> Transaction:
@payment_postprocess
def confirm(
payment: Payment,
- plugin_manager: "PluginsManager",
+ manager: "PluginsManager",
additional_data: Optional[dict] = None,
) -> Transaction:
txn = payment.transactions.filter(
@@ -237,7 +237,7 @@ def confirm(
payment=payment, payment_token=token, additional_data=additional_data
)
response, error = _fetch_gateway_response(
- plugin_manager.confirm_payment, payment.gateway, payment_data
+ manager.confirm_payment, payment.gateway, payment_data
)
action_required = response is not None and response.action_required
if response and response.payment_method_info:
@@ -253,13 +253,13 @@ def confirm(
def list_payment_sources(
- gateway: str, customer_id: str, plugin_manager: "PluginsManager"
+ gateway: str, customer_id: str, manager: "PluginsManager"
) -> List["CustomerSource"]:
- return plugin_manager.list_payment_sources(gateway, customer_id)
+ return manager.list_payment_sources(gateway, customer_id)
-def list_gateways(plugin_manager: "PluginsManager") -> List["PaymentGateway"]:
- return plugin_manager.list_payment_gateways()
+def list_gateways(manager: "PluginsManager") -> List["PaymentGateway"]:
+ return manager.list_payment_gateways()
def _fetch_gateway_response(fn, *args, **kwargs):
@@ -294,12 +294,10 @@ def _validate_refund_amount(payment: Payment, amount: Decimal):
raise PaymentError("Cannot refund more than captured.")
-def payment_refund_or_void(
- payment: Optional[Payment], plugin_manager: "PluginsManager"
-):
+def payment_refund_or_void(payment: Optional[Payment], manager: "PluginsManager"):
if payment is None:
return
if payment.can_refund():
- refund(payment, plugin_manager)
+ refund(payment, manager)
elif payment.can_void():
- void(payment, plugin_manager)
+ void(payment, manager)
diff --git a/saleor/payment/gateways/dummy/tests/test_dummy.py b/saleor/payment/gateways/dummy/tests/test_dummy.py
index cf53d185c7..48344220e7 100644
--- a/saleor/payment/gateways/dummy/tests/test_dummy.py
+++ b/saleor/payment/gateways/dummy/tests/test_dummy.py
@@ -14,7 +14,7 @@ def setup_dummy_gateway(settings):
def test_authorize_success(payment_dummy):
txn = gateway.authorize(
- payment=payment_dummy, token="Fake", plugin_manager=get_plugins_manager()
+ payment=payment_dummy, token="Fake", manager=get_plugins_manager()
)
assert txn.is_success
assert txn.kind == TransactionKind.AUTH
@@ -44,7 +44,7 @@ def test_authorize_failed(is_active, charge_status, payment_dummy):
payment.save()
with pytest.raises(PaymentError):
txn = gateway.authorize(
- payment=payment, token="Fake", plugin_manager=get_plugins_manager()
+ payment=payment, token="Fake", manager=get_plugins_manager()
)
assert txn is None
@@ -53,7 +53,7 @@ def test_authorize_gateway_error(payment_dummy, monkeypatch):
monkeypatch.setattr("saleor.payment.gateways.dummy.dummy_success", lambda: False)
with pytest.raises(PaymentError):
txn = gateway.authorize(
- payment=payment_dummy, token="Fake", plugin_manager=get_plugins_manager()
+ payment=payment_dummy, token="Fake", manager=get_plugins_manager()
)
assert txn.kind == TransactionKind.AUTH
assert not txn.is_success
@@ -63,9 +63,7 @@ def test_authorize_gateway_error(payment_dummy, monkeypatch):
def test_void_success(payment_txn_preauth):
assert payment_txn_preauth.is_active
assert payment_txn_preauth.charge_status == ChargeStatus.NOT_CHARGED
- txn = gateway.void(
- payment=payment_txn_preauth, plugin_manager=get_plugins_manager()
- )
+ txn = gateway.void(payment=payment_txn_preauth, manager=get_plugins_manager())
assert txn.is_success
assert txn.kind == TransactionKind.VOID
assert txn.payment == payment_txn_preauth
@@ -94,16 +92,14 @@ def test_void_failed(is_active, charge_status, payment_dummy):
payment.charge_status = charge_status
payment.save()
with pytest.raises(PaymentError):
- txn = gateway.void(payment=payment, plugin_manager=get_plugins_manager())
+ txn = gateway.void(payment=payment, manager=get_plugins_manager())
assert txn is None
def test_void_gateway_error(payment_txn_preauth, monkeypatch):
monkeypatch.setattr("saleor.payment.gateways.dummy.dummy_success", lambda: False)
with pytest.raises(PaymentError):
- txn = gateway.void(
- payment=payment_txn_preauth, plugin_manager=get_plugins_manager()
- )
+ txn = gateway.void(payment=payment_txn_preauth, manager=get_plugins_manager())
assert txn.kind == TransactionKind.VOID
assert not txn.is_success
assert txn.payment == payment_txn_preauth
@@ -116,7 +112,7 @@ def test_void_gateway_error(payment_txn_preauth, monkeypatch):
def test_capture_success(amount, charge_status, payment_txn_preauth):
txn = gateway.capture(
payment=payment_txn_preauth,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal(amount),
)
assert txn.is_success
@@ -146,7 +142,7 @@ def test_capture_failed(
payment.save()
with pytest.raises(PaymentError):
txn = gateway.capture(
- payment=payment, plugin_manager=get_plugins_manager(), amount=amount
+ payment=payment, manager=get_plugins_manager(), amount=amount
)
assert txn is None
@@ -155,7 +151,7 @@ def test_capture_gateway_error(payment_txn_preauth, monkeypatch):
monkeypatch.setattr("saleor.payment.gateways.dummy.dummy_success", lambda: False)
with pytest.raises(PaymentError):
txn = gateway.capture(
- payment=payment_txn_preauth, plugin_manager=get_plugins_manager(), amount=80
+ payment=payment_txn_preauth, manager=get_plugins_manager(), amount=80
)
assert txn.kind == TransactionKind.CAPTURE
assert not txn.is_success
@@ -186,7 +182,7 @@ def test_refund_success(
payment.save()
txn = gateway.refund(
payment=payment,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal(refund_amount),
)
@@ -219,7 +215,7 @@ def test_refund_failed(
with pytest.raises(PaymentError):
txn = gateway.refund(
payment=payment,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal(refund_amount),
)
assert txn is None
@@ -234,7 +230,7 @@ def test_refund_gateway_error(payment_txn_captured, monkeypatch):
with pytest.raises(PaymentError):
gateway.refund(
payment=payment,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal("80.00"),
)
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.py
index 9f79a0e4e6..63af452a36 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
@@ -38,7 +38,7 @@ def test_authorize_success(payment_dummy_credit_card):
txn = gateway.authorize(
payment=payment_dummy_credit_card,
token="Fake",
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
assert txn.is_success
assert txn.kind == TransactionKind.AUTH
@@ -67,9 +67,7 @@ def test_authorize_failed(is_active, charge_status, error, payment_dummy_credit_
payment.charge_status = charge_status
payment.save()
with pytest.raises(PaymentError) as e:
- gateway.authorize(
- payment=payment, token="Fake", plugin_manager=get_plugins_manager()
- )
+ gateway.authorize(payment=payment, token="Fake", manager=get_plugins_manager())
assert e._excinfo[1].message == error
@@ -82,7 +80,7 @@ def test_authorize_gateway_error(payment_dummy_credit_card, monkeypatch):
gateway.authorize(
payment=payment_dummy_credit_card,
token="Fake",
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
assert e._excinfo[1].message == "Unable to authorize transaction"
@@ -109,9 +107,7 @@ def test_void_success(payment_txn_preauth):
assert payment_txn_preauth.is_active
assert payment_txn_preauth.charge_status == ChargeStatus.NOT_CHARGED
- txn = gateway.void(
- payment=payment_txn_preauth, plugin_manager=get_plugins_manager()
- )
+ txn = gateway.void(payment=payment_txn_preauth, manager=get_plugins_manager())
assert txn.is_success
assert txn.kind == TransactionKind.VOID
assert txn.payment == payment_txn_preauth
@@ -140,7 +136,7 @@ def test_void_failed(is_active, charge_status, error, payment_dummy_credit_card)
payment.charge_status = charge_status
payment.save()
with pytest.raises(PaymentError) as e:
- gateway.void(payment=payment, plugin_manager=get_plugins_manager())
+ gateway.void(payment=payment, manager=get_plugins_manager())
assert e._excinfo[1].message == error
@@ -153,7 +149,7 @@ def test_void_gateway_error(payment_txn_preauth, monkeypatch):
"saleor.payment.gateways.dummy_credit_card.dummy_success", lambda: False
)
with pytest.raises(PaymentError) as e:
- gateway.void(payment=payment_txn_preauth, plugin_manager=get_plugins_manager())
+ gateway.void(payment=payment_txn_preauth, manager=get_plugins_manager())
assert e._excinfo[1].message == "Unable to void the transaction."
@@ -190,7 +186,7 @@ def test_capture_success(amount, charge_status, token, payment_txn_preauth):
txn = gateway.capture(
payment=payment_txn_preauth,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal(amount),
)
assert txn.is_success
@@ -220,9 +216,7 @@ def test_capture_failed(
payment.charge_status = charge_status
payment.save()
with pytest.raises(PaymentError) as e:
- gateway.capture(
- payment=payment, plugin_manager=get_plugins_manager(), amount=amount
- )
+ gateway.capture(payment=payment, manager=get_plugins_manager(), amount=amount)
assert e._excinfo[1].message == error
@@ -239,9 +233,7 @@ def test_capture_error_in_response(token, error, payment_txn_preauth):
# when
with pytest.raises(PaymentError) as e:
- gateway.capture(
- payment=payment_txn_preauth, plugin_manager=get_plugins_manager()
- )
+ gateway.capture(payment=payment_txn_preauth, manager=get_plugins_manager())
assert e._excinfo[1].message == error
@@ -287,7 +279,7 @@ def test_refund_success(
payment.save()
txn = gateway.refund(
payment=payment,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal(refund_amount),
)
@@ -324,7 +316,7 @@ def test_refund_failed(
with pytest.raises(PaymentError) as e:
gateway.refund(
payment=payment,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal(refund_amount),
)
@@ -343,7 +335,7 @@ def test_refund_gateway_error(payment_txn_captured, monkeypatch):
with pytest.raises(PaymentError):
gateway.refund(
payment=payment,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=Decimal("80.00"),
)
@@ -362,7 +354,7 @@ def test_process_payment_success(token, payment_dummy_credit_card):
txn = gateway.process_payment(
payment=payment_dummy_credit_card,
token=token,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
# then
@@ -381,7 +373,7 @@ def test_process_payment_failed(token, error, payment_dummy_credit_card):
gateway.process_payment(
payment=payment_dummy_credit_card,
token=token,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
assert e._excinfo[1].message == error
@@ -418,7 +410,7 @@ def test_process_payment_pre_authorized(
txn = gateway.process_payment(
payment=payment_dummy_credit_card,
token=token,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
# then
@@ -446,7 +438,7 @@ def test_process_payment_pre_authorized_and_capture(
txn = gateway.process_payment(
payment=payment_dummy_credit_card,
token=token,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
# then
@@ -475,7 +467,7 @@ def test_process_payment_pre_authorized_and_capture_error(
gateway.process_payment(
payment=payment_dummy_credit_card,
token=token,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
)
assert e._excinfo[1].message == TOKEN_VALIDATION_MAPPING[token]
diff --git a/saleor/payment/tests/test_gateway.py b/saleor/payment/tests/test_gateway.py
index 7012ff6844..e85168a381 100644
--- a/saleor/payment/tests/test_gateway.py
+++ b/saleor/payment/tests/test_gateway.py
@@ -87,7 +87,7 @@ def test_process_payment(fake_payment_interface, payment_txn_preauth):
fake_payment_interface.process_payment.return_value = PROCESS_PAYMENT_RESPONSE
transaction = gateway.process_payment(
- payment=payment_txn_preauth, token=TOKEN, plugin_manager=fake_payment_interface
+ payment=payment_txn_preauth, token=TOKEN, manager=fake_payment_interface
)
fake_payment_interface.process_payment.assert_called_once_with(
@@ -110,7 +110,7 @@ def test_store_source_when_processing_payment(
transaction = gateway.process_payment(
payment=payment_txn_preauth,
token=TOKEN,
- plugin_manager=fake_payment_interface,
+ manager=fake_payment_interface,
store_source=True,
)
@@ -127,7 +127,7 @@ def test_authorize_payment(fake_payment_interface, payment_dummy):
fake_payment_interface.authorize_payment.return_value = AUTHORIZE_RESPONSE
transaction = gateway.authorize(
- payment=payment_dummy, token=TOKEN, plugin_manager=fake_payment_interface
+ payment=payment_dummy, token=TOKEN, manager=fake_payment_interface
)
fake_payment_interface.authorize_payment.assert_called_once_with(
@@ -147,7 +147,7 @@ def test_capture_payment(fake_payment_interface, payment_txn_preauth):
fake_payment_interface.capture_payment.return_value = PROCESS_PAYMENT_RESPONSE
transaction = gateway.capture(
- payment=payment_txn_preauth, plugin_manager=fake_payment_interface
+ payment=payment_txn_preauth, manager=fake_payment_interface
)
fake_payment_interface.capture_payment.assert_called_once_with(
@@ -163,7 +163,7 @@ def test_refund_for_manual_payment(payment_txn_captured):
payment_txn_captured.gateway = CustomPaymentChoices.MANUAL
transaction = gateway.refund(
payment=payment_txn_captured,
- plugin_manager=get_plugins_manager(),
+ manager=get_plugins_manager(),
amount=PARTIAL_REFUND_AMOUNT,
)
payment_txn_captured.refresh_from_db()
@@ -183,7 +183,7 @@ def test_partial_refund_payment(fake_payment_interface, payment_txn_captured):
fake_payment_interface.refund_payment.return_value = PARTIAL_REFUND_RESPONSE
transaction = gateway.refund(
payment=payment_txn_captured,
- plugin_manager=fake_payment_interface,
+ manager=fake_payment_interface,
amount=PARTIAL_REFUND_AMOUNT,
)
fake_payment_interface.refund_payment.assert_called_once_with(
@@ -207,7 +207,7 @@ def test_full_refund_payment(fake_payment_interface, payment_txn_captured):
)
fake_payment_interface.refund_payment.return_value = FULL_REFUND_RESPONSE
transaction = gateway.refund(
- payment=payment_txn_captured, plugin_manager=fake_payment_interface
+ payment=payment_txn_captured, manager=fake_payment_interface
)
fake_payment_interface.refund_payment.assert_called_once_with(
USED_GATEWAY, PAYMENT_DATA
@@ -231,7 +231,7 @@ def test_void_payment(fake_payment_interface, payment_txn_preauth):
fake_payment_interface.void_payment.return_value = VOID_RESPONSE
transaction = gateway.void(
- payment=payment_txn_preauth, plugin_manager=fake_payment_interface
+ payment=payment_txn_preauth, manager=fake_payment_interface
)
fake_payment_interface.void_payment.assert_called_once_with(
@@ -255,7 +255,7 @@ def test_confirm_payment(fake_payment_interface, payment_txn_to_confirm):
fake_payment_interface.confirm_payment.return_value = CONFIRM_RESPONSE
transaction = gateway.confirm(
- payment=payment_txn_to_confirm, plugin_manager=fake_payment_interface
+ payment=payment_txn_to_confirm, manager=fake_payment_interface
)
fake_payment_interface.confirm_payment.assert_called_once_with(
diff --git a/saleor/product/tests/test_product_availability.py b/saleor/product/tests/test_product_availability.py
index 93b7085e47..99a9a3f552 100644
--- a/saleor/product/tests/test_product_availability.py
+++ b/saleor/product/tests/test_product_availability.py
@@ -29,7 +29,7 @@ def test_availability(stock, monkeypatch, settings, channel_USD):
variants=product.variants.all(),
variants_channel_listing=variants_channel_listing,
channel=channel_USD,
- plugins=manager,
+ manager=manager,
collections=[],
discounts=[],
country=Country("PL"),
@@ -52,7 +52,7 @@ def test_availability(stock, monkeypatch, settings, channel_USD):
collections=[],
discounts=[],
channel=channel_USD,
- plugins=manager,
+ manager=manager,
local_currency="PLN",
country=Country("PL"),
)
@@ -66,7 +66,7 @@ def test_availability(stock, monkeypatch, settings, channel_USD):
collections=[],
discounts=[],
channel=channel_USD,
- plugins=manager,
+ manager=manager,
country=Country("PL"),
)
assert availability.price_range.start.tax.amount
@@ -95,7 +95,7 @@ def test_availability_with_all_variant_channel_listings(stock, channel_USD):
variants=variants,
variants_channel_listing=variants_channel_listing,
channel=channel_USD,
- plugins=manager,
+ manager=manager,
collections=[],
discounts=[],
country=Country("PL"),
@@ -126,7 +126,7 @@ def test_availability_with_missing_variant_channel_listings(stock, channel_USD):
variants=variants,
variants_channel_listing=variants_channel_listing,
channel=channel_USD,
- plugins=manager,
+ manager=manager,
collections=[],
discounts=[],
country=Country("PL"),
@@ -155,7 +155,7 @@ def test_availability_without_variant_channel_listings(stock, channel_USD):
variants=variants,
variants_channel_listing=[],
channel=channel_USD,
- plugins=manager,
+ manager=manager,
collections=[],
discounts=[],
country=Country("PL"),
diff --git a/saleor/product/utils/availability.py b/saleor/product/utils/availability.py
index 1dc3a13c24..84fbbd1564 100644
--- a/saleor/product/utils/availability.py
+++ b/saleor/product/utils/availability.py
@@ -145,7 +145,7 @@ def get_product_availability(
collections: Iterable[Collection],
discounts: Iterable[DiscountInfo],
channel: Channel,
- plugins: "PluginsManager",
+ manager: "PluginsManager",
country: Optional[Country] = None,
local_currency: Optional[str] = None,
) -> ProductAvailability:
@@ -161,10 +161,10 @@ def get_product_availability(
)
if discounted_net_range is not None:
discounted = TaxedMoneyRange(
- start=plugins.apply_taxes_to_product(
+ start=manager.apply_taxes_to_product(
product, discounted_net_range.start, country
),
- stop=plugins.apply_taxes_to_product(
+ stop=manager.apply_taxes_to_product(
product, discounted_net_range.stop, country
),
)
@@ -180,10 +180,10 @@ def get_product_availability(
)
if undiscounted_net_range is not None:
undiscounted = TaxedMoneyRange(
- start=plugins.apply_taxes_to_product(
+ start=manager.apply_taxes_to_product(
product, undiscounted_net_range.start, country
),
- stop=plugins.apply_taxes_to_product(
+ stop=manager.apply_taxes_to_product(
product, undiscounted_net_range.stop, country
),
)