Skip to content

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

Fix review remarks

fowczarek1a93e134c9d5
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.py
index dde0a33a16..0e8e2709d7 100644
--- a/saleor/graphql/account/mutations.py
+++ b/saleor/graphql/account/mutations.py
@@ -152,14 +152,14 @@ class CustomerUpdate(CustomerCreate):
model = models.User
-class LoggedCustomerUpdate(CustomerCreate):
+class LoggedUserUpdate(CustomerCreate):
class Arguments:
input = UserAddressInput(
description='Fields required to update logged in customer.',
required=True)
class Meta:
- description = 'Updates an existing logged in customer.'
+ description = 'Updates data of the logged in user.'
exclude = ['password']
model = models.User
diff --git a/saleor/graphql/account/schema.py b/saleor/graphql/account/schema.py
index 38837ebbca..26190bd780 100644
--- a/saleor/graphql/account/schema.py
+++ b/saleor/graphql/account/schema.py
@@ -6,7 +6,7 @@ from ..descriptions import DESCRIPTIONS
from .mutations import (
AddressCreate, AddressDelete, AddressUpdate, CustomerCreate,
CustomerDelete, CustomerPasswordReset, CustomerRegister, CustomerUpdate,
- LoggedCustomerUpdate, PasswordReset, SetPassword, StaffCreate, StaffDelete,
+ LoggedUserUpdate, PasswordReset, SetPassword, StaffCreate, StaffDelete,
StaffUpdate)
from .resolvers import (
resolve_address_validator, resolve_customers, resolve_staff_users,
@@ -54,7 +54,7 @@ class AccountMutations(graphene.ObjectType):
customer_register = CustomerRegister.Field()
customer_update = CustomerUpdate.Field()
- logged_customer_update = LoggedCustomerUpdate.Field()
+ logged_user_update = LoggedUserUpdate.Field()
staff_create = StaffCreate.Field()
staff_delete = StaffDelete.Field()
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index d381cc5cb9..578a6e83fd 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -712,7 +712,7 @@ type LanguageDisplay {
language: String!
}
-type LoggedCustomerUpdate {
+type LoggedUserUpdate {
errors: [Error]
user: User
}
@@ -871,7 +871,7 @@ type Mutations {
setPassword(id: ID!, input: SetPasswordInput!): SetPassword
passwordReset(email: String!): PasswordReset
customerCreate(input: UserCreateInput!): CustomerCreate
- loggedCustomerUpdate(input: UserAddressInput!): LoggedCustomerUpdate
+ loggedUserUpdate(input: UserAddressInput!): LoggedUserUpdate
customerUpdate(id: ID!, input: CustomerInput!): CustomerUpdate
customerDelete(id: ID!): CustomerDelete
customerPasswordReset(input: CustomerPasswordResetInput!): CustomerPasswordReset
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index b4c84ff26b..0caa03b3da 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -143,7 +143,7 @@ def test_query_user(staff_api_client, customer_user, permission_manage_users):
assert address['phone'] == user_address.phone.as_e164
-def test_non_staff_user_can_see_his_user_data(user_api_client):
+def test_customer_can_see_his_user_data(user_api_client):
query = """
query User($id: ID!) {
user(id: $id) {
@@ -160,8 +160,8 @@ def test_non_staff_user_can_see_his_user_data(user_api_client):
assert data['email'] == user.email
-def test_non_staff_user_can_not_see_other_users_data(user_api_client,
- staff_user):
+def test_customer_can_not_see_other_users_data(user_api_client,
+ staff_user):
query = """
query User($id: ID!) {
user(id: $id) {
@@ -464,7 +464,7 @@ def test_logged_customer_update(user_api_client, address):
query = """
mutation UpdateLoggedCustomer($billing: AddressInput,
$shipping: AddressInput) {
- loggedCustomerUpdate(
+ loggedUserUpdate(
input: {
defaultBillingAddress: $billing,
defaultShippingAddress: $shipping,
@@ -491,35 +491,27 @@ def test_logged_customer_update(user_api_client, address):
user = user_api_client.user
assert user.default_billing_address
assert user.default_shipping_address
- billing_address_pk = user.default_billing_address.pk
- shipping_address_pk = user.default_shipping_address.pk
address_data = convert_dict_keys_to_camel_case(address.as_data())
-
new_street_address = 'Updated street address'
address_data['streetAddress1'] = new_street_address
-
variables = {
'billing': address_data,
'shipping': address_data}
response = user_api_client.post_graphql(query, variables)
content = get_graphql_content(response)
-
- User = get_user_model()
- customer = User.objects.get(email=user.email)
-
- customer_billing_address = customer.default_billing_address
- customer_shipping_address = customer.default_shipping_address
+ data = content['data']['loggedUserUpdate']
+ assert not data['errors']
# check that existing instances are updated
- assert customer_billing_address.pk == billing_address_pk
- assert customer_shipping_address.pk == shipping_address_pk
-
- assert customer_billing_address.street_address_1 == new_street_address
- assert customer_shipping_address.street_address_1 == new_street_address
+ billing_address_pk = user.default_billing_address.pk
+ shipping_address_pk = user.default_shipping_address.pk
+ user = User.objects.get(email=user.email)
+ assert user.default_billing_address.pk == billing_address_pk
+ assert user.default_shipping_address.pk == shipping_address_pk
- data = content['data']['loggedCustomerUpdate']
- assert data['errors'] == []
+ assert user.default_billing_address.street_address_1 == new_street_address
+ assert user.default_shipping_address.street_address_1 == new_street_address
def test_customer_delete(staff_api_client, customer_user, permission_manage_users):