Skip to content

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

Fix typo in promo code utils

fowczarek92aaf407f7cf
diff --git a/saleor/core/utils/promo_code.py b/saleor/core/utils/promo_code.py
index ba4f1ac5e3..d3e1df8ab0 100644
--- a/saleor/core/utils/promo_code.py
+++ b/saleor/core/utils/promo_code.py
@@ -7,12 +7,12 @@ from ...giftcard.models import GiftCard
def generate_promo_code(length=12):
"""Generate new unique gift card code."""
code = str(uuid.uuid4()).replace("-", "").upper()[:length]
- while not is_avaible_promo_code(code):
+ while not is_available_promo_code(code):
code = str(uuid.uuid4()).replace("-", "").upper()[:length]
return code
-def is_avaible_promo_code(code):
+def is_available_promo_code(code):
return not (promo_code_is_gift_card(code) or promo_code_is_voucher(code))
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.py
index 9d56407a88..351bed378f 100644
--- a/saleor/graphql/discount/mutations.py
+++ b/saleor/graphql/discount/mutations.py
@@ -1,7 +1,7 @@
import graphene
from django.core.exceptions import ObjectDoesNotExist, ValidationError
-from ...core.utils.promo_code import generate_promo_code, is_avaible_promo_code
+from ...core.utils.promo_code import generate_promo_code, is_available_promo_code
from ...discount import models
from ..core.mutations import BaseMutation, ModelDeleteMutation, ModelMutation
from ..core.scalars import Decimal
@@ -115,8 +115,8 @@ class VoucherCreate(ModelMutation):
code = data.get("code", None)
if code == "":
data["code"] = generate_promo_code()
- elif not is_avaible_promo_code(code):
- raise ValidationError({"code": "Voucher with this code is not avaible."})
+ elif not is_available_promo_code(code):
+ raise ValidationError({"code": "Voucher with this code is not available."})
cleaned_input = super().clean_input(info, instance, data)
return cleaned_input
diff --git a/saleor/graphql/giftcard/mutations.py b/saleor/graphql/giftcard/mutations.py
index 45ff4df43d..b29660e715 100644
--- a/saleor/graphql/giftcard/mutations.py
+++ b/saleor/graphql/giftcard/mutations.py
@@ -4,7 +4,7 @@ import graphene
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from ...account.models import User
-from ...core.utils.promo_code import generate_promo_code, is_avaible_promo_code
+from ...core.utils.promo_code import generate_promo_code, is_available_promo_code
from ...giftcard import models
from ..core.mutations import BaseMutation, ModelMutation
from ..core.scalars import Decimal
@@ -41,8 +41,10 @@ class GiftCardCreate(ModelMutation):
code = data.get("code", None)
if not code and not instance.pk:
data["code"] = generate_promo_code(16)
- elif not is_avaible_promo_code(code):
- raise ValidationError({"code": "Gift card with this code is not avaible."})
+ elif not is_available_promo_code(code):
+ raise ValidationError(
+ {"code": "Gift card with this code is not available."}
+ )
cleaned_input = super().clean_input(info, instance, data)
balance = cleaned_input.get("balance", None)
if balance:
diff --git a/tests/api/test_discount.py b/tests/api/test_discount.py
index 46d61ebd14..cbc445d852 100644
--- a/tests/api/test_discount.py
+++ b/tests/api/test_discount.py
@@ -242,7 +242,7 @@ def test_create_voucher_with_existing_gift_card_code(
errors = content["data"]["voucherCreate"]["errors"]
assert len(errors) == 1
assert errors[0]["field"] == "code"
- assert errors[0]["message"] == "Voucher with this code is not avaible."
+ assert errors[0]["message"] == "Voucher with this code is not available."
def test_create_voucher_with_existing_voucher_code(
@@ -270,7 +270,7 @@ def test_create_voucher_with_existing_voucher_code(
errors = content["data"]["voucherCreate"]["errors"]
assert len(errors) == 1
assert errors[0]["field"] == "code"
- assert errors[0]["message"] == "Voucher with this code is not avaible."
+ assert errors[0]["message"] == "Voucher with this code is not available."
def test_update_voucher(staff_api_client, voucher, permission_manage_discounts):
diff --git a/tests/api/test_gift_card.py b/tests/api/test_gift_card.py
index ff016a5935..2903dfbe12 100644
--- a/tests/api/test_gift_card.py
+++ b/tests/api/test_gift_card.py
@@ -237,7 +237,7 @@ def test_create_gift_card_with_existing_voucher_code(
errors = content["data"]["giftCardCreate"]["errors"]
assert len(errors) == 1
assert errors[0]["field"] == "code"
- assert errors[0]["message"] == "Gift card with this code is not avaible."
+ assert errors[0]["message"] == "Gift card with this code is not available."
def test_create_gift_card_with_existing_gift_card_code(
@@ -253,7 +253,7 @@ def test_create_gift_card_with_existing_gift_card_code(
errors = content["data"]["giftCardCreate"]["errors"]
assert len(errors) == 1
assert errors[0]["field"] == "code"
- assert errors[0]["message"] == "Gift card with this code is not avaible."
+ assert errors[0]["message"] == "Gift card with this code is not available."
def test_create_gift_card_without_user(staff_api_client, permission_manage_gift_card):