Skip to content

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

Merge master changes into the gql cleanup

NyanKiyoshi3fa43c6a1478
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.py
index 262317228d..0a895848dc 100644
--- a/saleor/graphql/account/mutations.py
+++ b/saleor/graphql/account/mutations.py
@@ -359,7 +359,7 @@ class PasswordReset(BaseMutation):
description = 'Sends password reset email'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('account.manage_users')
@classmethod
@@ -533,7 +533,7 @@ class AddressSetDefault(BaseMutation):
description = 'Sets a default address for the given user.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('account.manage_users')
@classmethod
@@ -610,12 +610,12 @@ class CustomerSetDefaultAddress(BaseMutation):
description = 'Sets a default address for the authenticated user.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.is_authenticated
@classmethod
def perform_mutation(cls, _root, info, **data):
- address = cls.get_node_or_error(info, id, Address)
+ address = cls.get_node_or_error(info, data.get('id'), Address)
user = info.context.user
if address not in user.addresses.all():
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index bb57f27f27..ecdc2c4fc7 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -182,8 +182,7 @@ class CheckoutCreate(ModelMutation, I18nMixin):
else:
checkout = models.Cart()
- cleaned_input = cls.clean_input(
- data.get('input'), checkout, input)
+ cleaned_input = cls.clean_input(info, checkout, data.get('input'))
checkout = cls.construct_instance(checkout, cleaned_input)
cls.clean_instance(checkout)
cls.save(info, checkout, cleaned_input)
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index 6c54f74b4b..b3e8b79fec 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -157,7 +157,7 @@ class BaseMutation(graphene.Mutation):
return instance
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
"""Determine whether user has rights to perform this mutation.
Default implementation assumes that user is allowed to perform any
@@ -169,7 +169,7 @@ class BaseMutation(graphene.Mutation):
@classmethod
def mutate(cls, root, info, **data):
- if not cls.user_is_allowed(info.context.user, data):
+ if not cls.user_is_allowed(info.context.user):
raise PermissionDenied()
try:
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.py
index db7e92b6fc..684f2f074e 100644
--- a/saleor/graphql/discount/mutations.py
+++ b/saleor/graphql/discount/mutations.py
@@ -164,7 +164,7 @@ class VoucherAddCatalogues(VoucherBaseCatalogueMutation):
description = 'Adds products, categories, collections to a voucher.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('discount.manage_discounts')
@classmethod
@@ -181,7 +181,7 @@ class VoucherRemoveCatalogues(VoucherBaseCatalogueMutation):
'Removes products, categories, collections from a voucher.')
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('discount.manage_discounts')
@classmethod
@@ -275,7 +275,7 @@ class SaleAddCatalogues(SaleBaseCatalogueMutation):
description = 'Adds products, categories, collections to a voucher.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('discount.manage_discounts')
@classmethod
@@ -291,7 +291,7 @@ class SaleRemoveCatalogues(SaleBaseCatalogueMutation):
description = 'Removes products, categories, collections from a sale.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('discount.manage_discounts')
@classmethod
diff --git a/saleor/graphql/menu/mutations.py b/saleor/graphql/menu/mutations.py
index fbec35f0d2..d214b6bb9a 100644
--- a/saleor/graphql/menu/mutations.py
+++ b/saleor/graphql/menu/mutations.py
@@ -209,7 +209,7 @@ class AssignNavigation(BaseMutation):
description = 'Assigns storefront\'s navigation menus.'
@classmethod
- def user_is_allowed(cls, instance, _data):
+ def user_is_allowed(cls, instance):
return instance.has_perms([
'menu.manage_menus', 'site.manage_settings'])
diff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.py
index cd9e2f6b01..641f830f0a 100644
--- a/saleor/graphql/order/mutations/draft_orders.py
+++ b/saleor/graphql/order/mutations/draft_orders.py
@@ -65,8 +65,8 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
@classmethod
def clean_input(cls, info, instance, raw_input):
- shipping_address = input.pop('shipping_address', None)
- billing_address = input.pop('billing_address', None)
+ shipping_address = raw_input.pop('shipping_address', None)
+ billing_address = raw_input.pop('billing_address', None)
cleaned_input = super().clean_input(info, instance, raw_input)
lines = raw_input.pop('lines', None)
@@ -176,7 +176,7 @@ class DraftOrderComplete(BaseMutation):
order.user = None
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -232,7 +232,7 @@ class DraftOrderLinesCreate(BaseMutation):
description = 'Create order lines for a draft order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -274,7 +274,7 @@ class DraftOrderLineDelete(BaseMutation):
description = 'Deletes an order line from a draft order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.py
index 6caa4b2a0d..c765990a03 100644
--- a/saleor/graphql/order/mutations/fulfillments.py
+++ b/saleor/graphql/order/mutations/fulfillments.py
@@ -124,7 +124,7 @@ class FulfillmentCreate(BaseMutation):
return fulfillment
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -159,7 +159,7 @@ class FulfillmentUpdateTracking(BaseMutation):
description = 'Updates a fulfillment for an order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -197,7 +197,7 @@ class FulfillmentCancel(BaseMutation):
and optionally restocks items.""")
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index 74024d4b6a..6935501879 100644
--- a/saleor/graphql/order/mutations/orders.py
+++ b/saleor/graphql/order/mutations/orders.py
@@ -114,7 +114,7 @@ class OrderUpdateShipping(BaseMutation):
description = 'Updates a shipping method of the order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -174,7 +174,7 @@ class OrderAddNote(BaseMutation):
description = 'Adds note to the order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -203,7 +203,7 @@ class OrderCancel(BaseMutation):
description = 'Cancel an order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -234,7 +234,7 @@ class OrderMarkAsPaid(BaseMutation):
description = 'Mark order as manually paid.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -262,7 +262,7 @@ class OrderCapture(BaseMutation):
description = 'Capture an order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -299,7 +299,7 @@ class OrderVoid(BaseMutation):
description = 'Void an order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -331,7 +331,7 @@ class OrderRefund(BaseMutation):
description = 'Refund an order.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
diff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.py
index 147e7936a8..cf326f65a6 100644
--- a/saleor/graphql/payment/mutations.py
+++ b/saleor/graphql/payment/mutations.py
@@ -104,7 +104,7 @@ class PaymentCapture(BaseMutation):
description = 'Captures the authorized payment amount'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -124,7 +124,7 @@ class PaymentRefund(PaymentCapture):
description = 'Refunds the captured payment amount'
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
@@ -148,7 +148,7 @@ class PaymentVoid(BaseMutation):
description = 'Voids the authorized payment'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('order.manage_orders')
@classmethod
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.py
index d31bb493d7..1802b512d7 100644
--- a/saleor/graphql/product/mutations/attributes.py
+++ b/saleor/graphql/product/mutations/attributes.py
@@ -2,6 +2,7 @@ import graphene
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.template.defaultfilters import slugify
+from graphql_jwt.decorators import permission_required
from ....product import models
from ...core.mutations import ModelDeleteMutation, ModelMutation
@@ -136,12 +137,11 @@ class AttributeCreate(AttributeMixin, ModelMutation):
model = models.Attribute
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
- @permission_required('product.manage_products')
- def mutate(cls, _root, info, **data):
+ def perform_mutation(cls, root, info, **data):
product_type = cls.get_node_or_error(
info, data.get('id'), only_type=ProductType)
instance = models.Attribute()
@@ -198,7 +198,7 @@ class AttributeUpdate(AttributeMixin, ModelMutation):
attribute_value.delete()
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -266,7 +266,7 @@ class AttributeValueCreate(ModelMutation):
return cleaned_input
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 53972315fc..4cc7e67f23 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -218,7 +218,7 @@ class CollectionAddProducts(BaseMutation):
description = 'Adds products to a collection.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -245,7 +245,7 @@ class CollectionRemoveProducts(BaseMutation):
description = 'Remove products from a collection.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -667,7 +667,7 @@ class ProductImageCreate(BaseMutation):
https://github.com/jaydenseric/graphql-multipart-request-spec''')
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -703,7 +703,7 @@ class ProductImageUpdate(BaseMutation):
description = 'Updates a product image.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -734,7 +734,7 @@ class ProductImageReorder(BaseMutation):
description = 'Changes ordering of the product image.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -776,7 +776,7 @@ class ProductImageDelete(BaseMutation):
description = 'Deletes a product image.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -806,7 +806,7 @@ class VariantImageAssign(BaseMutation):
description = 'Assign an image to a product variant'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
@@ -843,7 +843,7 @@ class VariantImageUnassign(BaseMutation):
description = 'Unassign an image from a product variant'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('product.manage_products')
@classmethod
diff --git a/saleor/graphql/shipping/mutations.py b/saleor/graphql/shipping/mutations.py
index f3a21e7389..4b7a3c36d1 100644
--- a/saleor/graphql/shipping/mutations.py
+++ b/saleor/graphql/shipping/mutations.py
@@ -204,7 +204,7 @@ class ShippingPriceDelete(BaseMutation):
description = 'Deletes a shipping price.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('shipping.manage_shipping')
@classmethod
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.py
index a02516af15..9dc6ff828c 100644
--- a/saleor/graphql/shop/mutations.py
+++ b/saleor/graphql/shop/mutations.py
@@ -48,7 +48,7 @@ class ShopSettingsUpdate(BaseMutation):
description = 'Updates shop settings'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_settings')
@classmethod
@@ -74,7 +74,7 @@ class ShopDomainUpdate(BaseMutation):
description = 'Updates site domain of the shop'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_settings')
@classmethod
@@ -99,7 +99,7 @@ class ShopFetchTaxRates(BaseMutation):
description = 'Fetch tax rates'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_settings')
@classmethod
@@ -123,7 +123,7 @@ class HomepageCollectionUpdate(BaseMutation):
description = 'Updates homepage collection of the shop'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_settings')
@classmethod
@@ -160,7 +160,7 @@ class AuthorizationKeyAdd(BaseMutation):
description='Fields required to create an authorization key.')
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_settings')
@classmethod
@@ -190,7 +190,7 @@ class AuthorizationKeyDelete(BaseMutation):
description = 'Deletes an authorization key.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_settings')
@classmethod
diff --git a/saleor/graphql/translations/mutations.py b/saleor/graphql/translations/mutations.py
index ff1ed8913b..812930c106 100644
--- a/saleor/graphql/translations/mutations.py
+++ b/saleor/graphql/translations/mutations.py
@@ -17,7 +17,7 @@ class BaseTranslateMutation(ModelMutation):
abstract = True
@classmethod
- def user_is_allowed(cls, user, input):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_translations')
@classmethod
@@ -214,7 +214,7 @@ class ShopSettingsTranslate(BaseMutation):
description = 'Creates/Updates translations for Shop Settings.'
@classmethod
- def user_is_allowed(cls, user, _data):
+ def user_is_allowed(cls, user):
return user.has_perm('site.manage_translations')
@classmethod
diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.py
index cceec3f5f8..67a99a1d8b 100644
--- a/tests/api/test_attributes.py
+++ b/tests/api/test_attributes.py
@@ -149,12 +149,12 @@ CREATE_ATTRIBUTES_QUERY = """
def test_create_attribute_and_attribute_values(
staff_api_client, permission_manage_products, product_type):
query = CREATE_ATTRIBUTES_QUERY
- id = graphene.Node.to_global_id('ProductType', product_type.id)
+ node_id = graphene.Node.to_global_id('ProductType', product_type.id)
attribute_name = 'Example name'
name = 'Value name'
variables = {
- 'name': attribute_name, 'id': id,
+ 'name': attribute_name, 'id': node_id,
'type': AttributeTypeEnum.PRODUCT.name,
'values': [{'name': name, 'value': '#1231'}]}
response = staff_api_client.post_graphql(
@@ -185,9 +185,9 @@ def test_create_attribute_and_attribute_values_errors(
staff_api_client, name_1, name_2, error_msg,
permission_manage_products, product_type):
query = CREATE_ATTRIBUTES_QUERY
- id = graphene.Node.to_global_id('ProductType', product_type.id)
+ node_id = graphene.Node.to_global_id('ProductType', product_type.id)
variables = {
- 'name': 'Example name', 'id': id,
+ 'name': 'Example name', 'id': node_id,
'type': AttributeTypeEnum.PRODUCT.name,
'values': [
{'name': name_1, 'value': '#1231'},
@@ -207,10 +207,10 @@ def test_create_variant_attribute(
product_type.save()
query = CREATE_ATTRIBUTES_QUERY
- id = graphene.Node.to_global_id('ProductType', product_type.id)
+ node_id = graphene.Node.to_global_id('ProductType', product_type.id)
attribute_name = 'Example name'
variables = {
- 'name': attribute_name, 'id': id,
+ 'name': attribute_name, 'id': node_id,
'type': AttributeTypeEnum.VARIANT.name, 'values': []}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
@@ -269,8 +269,9 @@ def test_update_attribute_name(
query = UPDATE_ATTRIBUTE_QUERY
attribute = color_attribute
name = 'Wings name'
- id = graphene.Node.to_global_id('Attribute', attribute.id)
- variables = {'name': name, 'id': id, 'addValues': [], 'removeValues': []}
+ node_id = graphene.Node.to_global_id('Attribute', attribute.id)
+ variables = {
+ 'name': name, 'id': node_id, 'addValues': [], 'removeValues': []}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
content = get_graphql_content(response)
@@ -286,12 +287,12 @@ def test_update_attribute_remove_and_add_values(
attribute = color_attribute
name = 'Wings name'
attribute_value_name = 'Red Color'
- id = graphene.Node.to_global_id('Attribute', attribute.id)
+ node_id = graphene.Node.to_global_id('Attribute', attribute.id)
attribute_value_id = attribute.values.first().id
value_id = graphene.Node.to_global_id(
'AttributeValue', attribute_value_id)
variables = {
- 'name': name, 'id': id,
+ 'name': name, 'id': node_id,
'addValues': [{'name': attribute_value_name, 'value': '#1231'}],
'removeValues': [value_id]}
response = staff_api_client.post_graphql(
@@ -312,14 +313,14 @@ def test_update_empty_attribute_and_add_values(
attribute = color_attribute_without_values
name = 'Wings name'
attribute_value_name = 'Yellow Color'
- id = graphene.Node.to_global_id('Attribute', attribute.id)
+ node_id = graphene.Node.to_global_id('Attribute', attribute.id)
variables = {
- 'name': name, 'id': id,
+ 'name': name, 'id': node_id,
'addValues': [{'name': attribute_value_name, 'value': '#1231'}],
'removeValues': []}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
- content = get_graphql_content(response)
+ get_graphql_content(response)
attribute.refresh_from_db()
assert attribute.values.count() == 1
assert attribute.values.filter(name=attribute_value_name).exists()
@@ -338,9 +339,9 @@ def test_update_attribute_and_add_attribute_values_errors(
permission_manage_products):
query = UPDATE_ATTRIBUTE_QUERY
attribute = color_attribute
- id = graphene.Node.to_global_id('Attribute', attribute.id)
+ node_id = graphene.Node.to_global_id('Attribute', attribute.id)
variables = {
- 'name': 'Example name', 'id': id, 'removeValues': [],
+ 'name': 'Example name', 'id': node_id, 'removeValues': [],
'addValues': [
{'name': name_1, 'value': '#1'}, {'name': name_2, 'value': '#2'}]}
response = staff_api_client.post_graphql(
@@ -357,12 +358,12 @@ def test_update_attribute_and_remove_others_attribute_value(
permission_manage_products):
query = UPDATE_ATTRIBUTE_QUERY
attribute = color_attribute
- id = graphene.Node.to_global_id('Attribute', attribute.id)
+ node_id = graphene.Node.to_global_id('Attribute', attribute.id)
size_attribute = size_attribute.values.first()
attr_id = graphene.Node.to_global_id(
'AttributeValue', size_attribute.pk)
variables = {
- 'name': 'Example name', 'id': id, 'slug': 'example-slug',
+ 'name': 'Example name', 'id': node_id, 'slug': 'example-slug',
'addValues': [], 'removeValues': [attr_id]}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
@@ -395,8 +396,8 @@ def test_delete_attribute(
}
}
"""
- id = graphene.Node.to_global_id('Attribute', attribute.id)
- variables = {'id': id}
+ node_id = graphene.Node.to_global_id('Attribute', attribute.id)
+ variables = {'id': node_id}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
content = get_graphql_content(response)
@@ -499,9 +500,9 @@ def test_update_attribute_value(
staff_api_client, pink_attribute_value, permission_manage_products):
query = UPDATE_ATTRIBUTE_VALUE_QUERY
value = pink_attribute_value
- id = graphene.Node.to_global_id('AttributeValue', value.id)
+ node_id = graphene.Node.to_global_id('AttributeValue', value.id)
name = 'Crimson name'
- variables = {'name': name, 'value': '#RED', 'id': id}
+ variables = {'name': name, 'value': '#RED', 'id': node_id}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
content = get_graphql_content(response)
@@ -517,8 +518,9 @@ def test_update_attribute_value_name_not_unique(
query = UPDATE_ATTRIBUTE_VALUE_QUERY
value = pink_attribute_value.attribute.values.create(
name='Example Name', slug='example-name', value='#RED')
- id = graphene.Node.to_global_id('AttributeValue', value.id)
- variables = {'name': pink_attribute_value.name, 'value': '#RED', 'id': id}
+ node_id = graphene.Node.to_global_id('AttributeValue', value.id)
+ variables = {
+ 'name': pink_attribute_value.name, 'value': '#RED', 'id': node_id}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
content = get_graphql_content(response)
@@ -532,9 +534,9 @@ def test_update_same_attribute_value(
staff_api_client, pink_attribute_value, permission_manage_products):
query = UPDATE_ATTRIBUTE_VALUE_QUERY
value = pink_attribute_value
- id = graphene.Node.to_global_id('AttributeValue', value.id)
+ node_id = graphene.Node.to_global_id('AttributeValue', value.id)
attr_value = '#BLUE'
- variables = {'name': value.name, 'value': attr_value, 'id': id}
+ variables = {'name': value.name, 'value': attr_value, 'id': node_id}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
content = get_graphql_content(response)
@@ -546,7 +548,6 @@ def test_update_same_attribute_value(
def test_delete_attribute_value(
staff_api_client, color_attribute, pink_attribute_value,
permission_manage_products):
- value = pink_attribute_value
value = color_attribute.values.get(name='Red')
query = """
mutation updateChoice($id: ID!) {
@@ -558,9 +559,9 @@ def test_delete_attribute_value(
}
}
"""
- id = graphene.Node.to_global_id('AttributeValue', value.id)
- variables = {'id': id}
- response = staff_api_client.post_graphql(
+ node_id = graphene.Node.to_global_id('AttributeValue', value.id)
+ variables = {'id': node_id}
+ staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
with pytest.raises(value._meta.model.DoesNotExist):
value.refresh_from_db()