Skip to content

Commit

Permalink
Fix passing args to list_stored_payment_methods (#15912)
Browse files Browse the repository at this point in the history
  • Loading branch information
maarcingebala committed May 6, 2024
1 parent cf9ee4d commit 590ab64
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 1 addition & 3 deletions saleor/graphql/account/tests/queries/test_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
7 changes: 3 additions & 4 deletions saleor/graphql/account/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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,
Expand Down Expand Up @@ -696,15 +697,13 @@ def resolve_stored_payment_methods(
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(
[
Expand Down
8 changes: 2 additions & 6 deletions saleor/graphql/checkout/tests/test_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] == []


Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions saleor/graphql/checkout/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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,
Expand Down Expand Up @@ -1243,15 +1244,15 @@ def resolve_stored_payment_methods(
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)
Expand Down

0 comments on commit 590ab64

Please sign in to comment.