Skip to content

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

Remove gift card verify mutation

fowczarek5058d2a1429f
diff --git a/saleor/graphql/giftcard/mutations.py b/saleor/graphql/giftcard/mutations.py
index b3f358a200..e2315d210d 100644
--- a/saleor/graphql/giftcard/mutations.py
+++ b/saleor/graphql/giftcard/mutations.py
@@ -115,32 +115,7 @@ class GiftCardActivate(BaseMutation):
gift_card = cls.get_node_or_error(
info, gift_card_id, field="gift_card_id", only_type=GiftCard
)
- if not gift_card.is_active:
+ if not gift_card.is_active:
gift_card.is_active = True
gift_card.save(update_fields=["is_active"])
return GiftCardDeactivate(gift_card=gift_card)
-
-
-class GiftCardVerify(BaseMutation):
- gift_card = graphene.Field(GiftCard, description="A gift card to verify.")
-
- class Arguments:
- code = graphene.String(required=True, description="Code of a gift card.")
-
- class Meta:
- description = "Verify a gift card."
-
- @classmethod
- def perform_mutation(cls, _root, info, **data):
- code = data.get("code")
- try:
- gift_card = models.GiftCard.objects.get(code=code)
- except models.GiftCard.DoesNotExist:
- gift_card = None
- raise ValidationError({"code": "Incorrect gift card code."})
- if gift_card:
- if not gift_card.is_active:
- raise ValidationError({"is_active": "Gift card is inactive."})
- if gift_card.end_date and date.today() > gift_card.end_date:
- raise ValidationError({"end_date": "Gift card expired."})
- return GiftCardDeactivate(gift_card=gift_card)
diff --git a/saleor/graphql/giftcard/schema.py b/saleor/graphql/giftcard/schema.py
index 22f978181e..0e6b575755 100644
--- a/saleor/graphql/giftcard/schema.py
+++ b/saleor/graphql/giftcard/schema.py
@@ -8,7 +8,6 @@ from .mutations import (
GiftCardCreate,
GiftCardDeactivate,
GiftCardUpdate,
- GiftCardVerify,
)
from .resolvers import resolve_gift_card
from .types import GiftCard
@@ -35,4 +34,3 @@ class GiftCardMutations(graphene.ObjectType):
gift_card_create = GiftCardCreate.Field()
gift_card_deactivate = GiftCardDeactivate.Field()
gift_card_update = GiftCardUpdate.Field()
- gift_card_verify = GiftCardVerify.Field()
diff --git a/tests/api/test_gift_card.py b/tests/api/test_gift_card.py
index 80e2b33792..d97b45aaa1 100644
--- a/tests/api/test_gift_card.py
+++ b/tests/api/test_gift_card.py
@@ -477,70 +477,3 @@ def test_activate_gift_card_active_gift_card(
content = get_graphql_content(response)
data = content["data"]["giftCardActivate"]["giftCard"]
assert data["isActive"]
-
-
-VERIFY_CODE_GIFT_CARD_MUTATION = """
-mutation giftCardVerify($code: String!) {
- giftCardVerify(code: $code){
- errors {
- field
- message
- }
- giftCard{
- code
- currentBalance {
- amount
- }
- }
- }
-}
-"""
-
-
-def test_verify_gift_card_code(user_api_client, gift_card):
- variables = {"code": gift_card.code}
- response = user_api_client.post_graphql(VERIFY_CODE_GIFT_CARD_MUTATION, variables)
- content = get_graphql_content(response)
- data = content["data"]["giftCardVerify"]["giftCard"]
- assert data["code"] == gift_card.code
- assert data["currentBalance"]["amount"] == gift_card.current_balance
-
-
-def test_verify_gift_card_code_incorect_code(user_api_client):
- variables = {"code": "incorect_code"}
- response = user_api_client.post_graphql(VERIFY_CODE_GIFT_CARD_MUTATION, variables)
- content = get_graphql_content(response)
- assert content["data"]["giftCardVerify"]["errors"]
- errors = content["data"]["giftCardVerify"]["errors"]
- assert len(errors) == 1
- assert errors[0]["field"] == "code"
- assert errors[0]["message"] == "Incorrect gift card code."
- assert not content["data"]["giftCardVerify"]["giftCard"]
-
-
-def test_verify_gift_card_code_inactive_code(user_api_client, gift_card):
- gift_card.is_active = False
- gift_card.save(update_fields=["is_active"])
- variables = {"code": gift_card.code}
- response = user_api_client.post_graphql(VERIFY_CODE_GIFT_CARD_MUTATION, variables)
- content = get_graphql_content(response)
- assert content["data"]["giftCardVerify"]["errors"]
- errors = content["data"]["giftCardVerify"]["errors"]
- assert len(errors) == 1
- assert errors[0]["field"] == "isActive"
- assert errors[0]["message"] == "Gift card is inactive."
- assert not content["data"]["giftCardVerify"]["giftCard"]
-
-
-def test_verify_gift_card_code_expired_code(user_api_client, gift_card):
- gift_card.end_date = date.today() - timedelta(days=3)
- gift_card.save(update_fields=["end_date"])
- variables = {"code": gift_card.code}
- response = user_api_client.post_graphql(VERIFY_CODE_GIFT_CARD_MUTATION, variables)
- content = get_graphql_content(response)
- assert content["data"]["giftCardVerify"]["errors"]
- errors = content["data"]["giftCardVerify"]["errors"]
- assert len(errors) == 1
- assert errors[0]["field"] == "endDate"
- assert errors[0]["message"] == "Gift card expired."
- assert not content["data"]["giftCardVerify"]["giftCard"]