Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix #9174 (#9498)
Seth Thoburnef015dd00355
diff --git a/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py b/saleor/graphql/checkout/mutations/checkout_delivery_method_update.pyindex 8b02708312..a3cf5ff640 100644--- a/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py+++ b/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py@@ -91,6 +91,16 @@ class CheckoutDeliveryMethodUpdate(BaseMutation):shipping_method_id=shipping_method_id,)+ if delivery_method is None and shipping_method_id:+ raise ValidationError(+ {+ "delivery_method_id": ValidationError(+ f"Couldn't resolve to a node: ${shipping_method_id}",+ code=CheckoutErrorCode.NOT_FOUND,+ )+ }+ )+cls._check_delivery_method(checkout_info, lines, shipping_method=delivery_method, collection_point=None)diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.pyindex b89f503650..990eec1ce3 100644--- a/saleor/graphql/checkout/tests/test_checkout.py+++ b/saleor/graphql/checkout/tests/test_checkout.py@@ -4051,6 +4051,41 @@ def test_checkout_delivery_method_update_with_id_of_different_type_causes_and_erassert checkout.collection_point is None+@patch(+ "saleor.graphql.checkout.mutations.checkout_shipping_method_update."+ "clean_delivery_method"+)+def test_checkout_delivery_method_with_nonexistant_id_results_not_found(+ mock_clean_delivery,+ api_client,+ warehouse_for_cc,+ checkout_with_item,+ address,+):+ checkout = checkout_with_item+ checkout.shipping_address = address+ checkout.save(update_fields=["shipping_address"])+ query = MUTATION_UPDATE_DELIVERY_METHOD+ mock_clean_delivery.return_value = True++ nonexistant_id = "YXBwOjEyMzQ6c29tZS1pZA=="+ response = api_client.post_graphql(+ query,+ {+ "token": checkout.token,+ "deliveryMethodId": nonexistant_id,+ },+ )+ data = get_graphql_content(response)["data"]["checkoutDeliveryMethodUpdate"]+ checkout.refresh_from_db()++ assert not data["checkout"]+ assert data["errors"][0]["field"] == "deliveryMethodId"+ assert data["errors"][0]["code"] == CheckoutErrorCode.NOT_FOUND.name+ assert checkout.shipping_method is None+ assert checkout.collection_point is None++@patch("saleor.graphql.checkout.mutations.checkout_shipping_method_update.""clean_delivery_method"