Skip to content

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

Fix passing args to list_stored_payment_methods (#15911)

Marcin Gębalab3712b0ad522
diff --git a/saleor/graphql/account/tests/queries/test_me.py b/saleor/graphql/account/tests/queries/test_me.py
index 2ed22c3e10..d012191d31 100644
--- a/saleor/graphql/account/tests/queries/test_me.py
+++ b/saleor/graphql/account/tests/queries/test_me.py
@@ -375,9 +375,7 @@ def test_me_query_stored_payment_methods(
)
# then
- mocked_list_stored_payment_methods.assert_called_once_with(
- request_data, channel_slug=channel_USD.slug
- )
+ mocked_list_stored_payment_methods.assert_called_once_with(request_data)
content = get_graphql_content(response)
data = content["data"]["me"]
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.py
index 11502adaa7..d7cafc98c0 100644
--- a/saleor/graphql/account/types.py
+++ b/saleor/graphql/account/types.py
@@ -15,6 +15,7 @@ from ...order import OrderStatus
from ...payment.interface import ListStoredPaymentMethodsRequestData
from ...permission.auth_filters import AuthorizationFilters
from ...permission.enums import AccountPermissions, AppPermission, OrderPermissions
+from ...plugins.manager import PluginsManager
from ...thumbnail.utils import (
get_image_or_proxy_url,
get_thumbnail_format,
@@ -701,15 +702,13 @@ class User(ModelObjectType[models.User]):
if not requestor or requestor.id != root.id:
return []
- def get_stored_payment_methods(data):
+ def get_stored_payment_methods(data: tuple[Channel, "PluginsManager"]):
channel_obj, manager = data
request_data = ListStoredPaymentMethodsRequestData(
user=root,
channel=channel_obj,
)
- return manager.list_stored_payment_methods(
- request_data, channel_slug=channel
- )
+ return manager.list_stored_payment_methods(request_data)
return Promise.all(
[
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.py
index 3d342aa9cf..2d44994866 100644
--- a/saleor/graphql/checkout/tests/test_checkout.py
+++ b/saleor/graphql/checkout/tests/test_checkout.py
@@ -2708,9 +2708,7 @@ def test_checkout_with_stored_payment_methods_empty_response(
# then
content = get_graphql_content(response)
- mocked_list_stored_payment_methods.assert_called_once_with(
- request_data, channel_slug=checkout_with_prices.channel.slug
- )
+ mocked_list_stored_payment_methods.assert_called_once_with(request_data)
assert content["data"]["checkout"]["storedPaymentMethods"] == []
@@ -2781,9 +2779,7 @@ def test_checkout_with_stored_payment_methods(
# then
content = get_graphql_content(response)
- mocked_list_stored_payment_methods.assert_called_once_with(
- request_data, channel_slug=checkout_with_prices.channel.slug
- )
+ mocked_list_stored_payment_methods.assert_called_once_with(request_data)
assert content["data"]["checkout"]["storedPaymentMethods"] == [
{
"id": payment_method_id,
diff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.py
index bfccba5d09..e39fe12800 100644
--- a/saleor/graphql/checkout/types.py
+++ b/saleor/graphql/checkout/types.py
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
import graphene
from promise import Promise
+from ...account.models import User
from ...checkout import calculations, models, problems
from ...checkout.base_calculations import (
calculate_undiscounted_base_line_total_price,
@@ -1282,15 +1283,15 @@ class Checkout(ModelObjectType[models.Checkout]):
if not requestor or requestor.id != root.user_id:
return []
- def _resolve_stored_payment_methods(data):
+ def _resolve_stored_payment_methods(
+ data: tuple["Channel", "User", "PluginsManager"],
+ ):
channel, user, manager = data
request_data = ListStoredPaymentMethodsRequestData(
user=user,
channel=channel,
)
- return manager.list_stored_payment_methods(
- request_data, channel_slug=channel.slug
- )
+ return manager.list_stored_payment_methods(request_data)
manager = get_plugin_manager_promise(info.context)
channel_loader = ChannelByIdLoader(info.context).load(root.channel_id)