Skip to content

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

remove duplicated tests

Maciej Korycinski6350993b15d0
diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.py
index a7325ee93a..e11097a6e8 100644
--- a/tests/api/test_checkout.py
+++ b/tests/api/test_checkout.py
@@ -7,7 +7,7 @@ from django.core.exceptions import ValidationError
from prices import TaxedMoney
from saleor.checkout.models import Checkout
-from saleor.checkout.utils import add_voucher_to_checkout, clean_checkout, is_fully_paid
+from saleor.checkout.utils import clean_checkout, is_fully_paid
from saleor.core.taxes import ZERO_MONEY
from saleor.graphql.core.utils import str_to_enum
from saleor.order.models import Order
@@ -1389,142 +1389,3 @@ def test_is_fully_paid_no_payment(checkout_with_item):
checkout = checkout_with_item
is_paid = is_fully_paid(checkout, None)
assert not is_paid
-
-
-MUTATION_CHECKOUT_UPDATE_VOUCHER = """
- mutation($checkoutId: ID!, $voucherCode: String) {
- checkoutUpdateVoucher(
- checkoutId: $checkoutId, voucherCode: $voucherCode) {
- errors {
- field
- message
- }
- checkout {
- id,
- voucherCode
- }
- }
- }
-"""
-
-
-def _mutate_checkout_update_voucher(client, variables):
- response = client.post_graphql(MUTATION_CHECKOUT_UPDATE_VOUCHER, variables)
- content = get_graphql_content(response)
- return content["data"]["checkoutUpdateVoucher"]
-
-
-def test_checkout_add_voucher(api_client, checkout_with_item, voucher):
- checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)
- variables = {"checkoutId": checkout_id, "voucherCode": voucher.code}
- data = _mutate_checkout_update_voucher(api_client, variables)
-
- assert not data["errors"]
- assert data["checkout"]["id"] == checkout_id
- assert data["checkout"]["voucherCode"] == voucher.code
-
-
-def test_checkout_remove_voucher(api_client, checkout_with_item):
- checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)
- variables = {"checkoutId": checkout_id}
- data = _mutate_checkout_update_voucher(api_client, variables)
-
- assert not data["errors"]
- assert data["checkout"]["id"] == checkout_id
- assert data["checkout"]["voucherCode"] is None
- assert checkout_with_item.voucher_code is None
-
-
-def test_checkout_add_voucher_invalid_checkout(api_client, voucher):
- variables = {"checkoutId": "XXX", "voucherCode": voucher.code}
- data = _mutate_checkout_update_voucher(api_client, variables)
-
- assert data["errors"]
- assert data["errors"][0]["field"] == "checkoutId"
-
-
-def test_checkout_add_voucher_invalid_code(api_client, checkout_with_item):
- checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)
- variables = {"checkoutId": checkout_id, "voucherCode": "XXX"}
- data = _mutate_checkout_update_voucher(api_client, variables)
-
- assert data["errors"]
- assert data["errors"][0]["field"] == "voucherCode"
-
-
-def test_checkout_add_voucher_not_applicable_voucher(
- api_client, checkout_with_item, voucher_with_high_min_amount_spent
-):
- checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)
- variables = {
- "checkoutId": checkout_id,
- "voucherCode": voucher_with_high_min_amount_spent.code,
- }
- data = _mutate_checkout_update_voucher(api_client, variables)
-
- assert data["errors"]
- assert data["errors"][0]["field"] == "voucherCode"
-
-
-def test_checkout_lines_delete_with_not_applicable_voucher(
- user_api_client, checkout_with_item, voucher
-):
- subtotal = checkout_with_item.get_subtotal()
- voucher.min_amount_spent = TaxedMoney(subtotal, subtotal).gross
- voucher.save(update_fields=["min_amount_spent"])
-
- add_voucher_to_checkout(checkout_with_item, voucher)
- assert checkout_with_item.voucher_code == voucher.code
-
- line = checkout_with_item.lines.first()
-
- checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)
- line_id = graphene.Node.to_global_id("CheckoutLine", line.pk)
- variables = {"checkoutId": checkout_id, "lineId": line_id}
- response = user_api_client.post_graphql(MUTATION_CHECKOUT_LINES_DELETE, variables)
- content = get_graphql_content(response)
-
- data = content["data"]["checkoutLineDelete"]
- assert not data["errors"]
- checkout_with_item.refresh_from_db()
- assert checkout_with_item.lines.count() == 0
- assert checkout_with_item.voucher_code is None
-
-
-def test_checkout_shipping_address_update_with_not_applicable_voucher(
- user_api_client,
- checkout_with_item,
- voucher_shipping_type,
- graphql_address_data,
- address_other_country,
- shipping_method,
-):
- assert checkout_with_item.shipping_address is None
- assert checkout_with_item.voucher_code is None
-
- checkout_with_item.shipping_address = address_other_country
- checkout_with_item.shipping_method = shipping_method
- checkout_with_item.save(update_fields=["shipping_address", "shipping_method"])
- assert checkout_with_item.shipping_address.country == address_other_country.country
-
- voucher = voucher_shipping_type
- assert voucher.countries[0].code == address_other_country.country
-
- add_voucher_to_checkout(checkout_with_item, voucher)
- assert checkout_with_item.voucher_code == voucher.code
-
- checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)
- new_address = graphql_address_data
- variables = {"checkoutId": checkout_id, "shippingAddress": new_address}
- response = user_api_client.post_graphql(
- MUTATION_CHECKOUT_SHIPPING_ADDRESS_UPDATE, variables
- )
- content = get_graphql_content(response)
- data = content["data"]["checkoutShippingAddressUpdate"]
- assert not data["errors"]
-
- checkout_with_item.refresh_from_db()
- checkout_with_item.shipping_address.refresh_from_db()
-
- assert checkout_with_item.shipping_address.country == new_address["country"]
- assert checkout_with_item.voucher_code is None