Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Added some checkout shipping address checks that were missing
NyanKiyoshi838135f81ca9
diff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.pyindex 5c26584471..ad7135d9fd 100644--- a/saleor/checkout/views/__init__.py+++ b/saleor/checkout/views/__init__.py@@ -84,8 +84,8 @@ def checkout_shipping_method(request, cart):def checkout_summary(request, cart):"""Display the correct order summary."""if cart.is_shipping_required():- view = validate_shipping_address(summary_with_shipping_view)- view = validate_shipping_method(view)+ view = validate_shipping_method(summary_with_shipping_view)+ view = validate_shipping_address(view)return view(request, cart)if request.user.is_authenticated:return summary_without_shipping(request, cart)diff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex d474a6e5c1..6a9b816230 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -82,6 +82,26 @@ def test_view_checkout_shipping_address(client, request_cart_with_item):assert request_cart_with_item.email == '[email protected]'+def test_view_checkout_shipping_address_with_invalid_data(+ client, request_cart_with_item):+ url = reverse('checkout:shipping-address')+ data = {+ 'email': '[email protected]',+ 'first_name': 'John',+ 'last_name': 'Doe',+ 'street_address_1': 'Aleje Jerozolimskie 2',+ 'street_address_2': '',+ 'city': 'Warszawa',+ 'city_area': '',+ 'country_area': '',+ 'postal_code': '00-37412',+ 'phone': '+48536984008',+ 'country': 'PL'}++ response = client.post(url, data, follow=True)+ assert response.request['PATH_INFO'] == url++def test_view_checkout_shipping_address_authorized_user(authorized_client, customer_user, request_cart_with_item):request_cart_with_item.user = customer_user@@ -263,14 +283,17 @@ def test_view_checkout_summary_without_address(request_cart_with_item, client):response = client.get(url)assert response.status_code == 302- redirect_url = reverse('checkout:shipping-method')+ redirect_url = reverse('checkout:shipping-address')assert get_redirect_location(response) == redirect_urldef test_view_checkout_summary_without_shipping_method(- request_cart_with_item, client):- url = reverse('checkout:summary')+ request_cart_with_item, client, address):+ request_cart_with_item.shipping_address = address+ request_cart_with_item.email = '[email protected]'+ request_cart_with_item.save()+ url = reverse('checkout:summary')response = client.get(url)assert response.status_code == 302@@ -388,7 +411,7 @@ def test_view_checkout_place_order_with_item_out_of_stock(variant.save()checkout_url = reverse('checkout:summary')- cart_url = reverse('cart:index')+ redirect_url = reverse('cart:index')# place orderdata = {'address': 'shipping_address'}@@ -396,7 +419,32 @@ def test_view_checkout_place_order_with_item_out_of_stock(# order should have been aborted,# and user should have been redirected to its cart- assert response.request['PATH_INFO'] == cart_url+ assert response.request['PATH_INFO'] == redirect_url+++def test_view_checkout_place_order_without_shipping_address(+ client, request_cart_with_item, shipping_method):++ cart = request_cart_with_item++ # add shipping information to the cart+ cart.email = '[email protected]'+ cart.shipping_method = (+ shipping_method.price_per_country.first())++ # save the cart+ cart.save()++ checkout_url = reverse('checkout:summary')+ redirect_url = reverse('checkout:shipping-address')++ # place order+ data = {'address': 'shipping_address'}+ response = client.post(checkout_url, data, follow=True)++ # order should have been aborted,+ # and user should have been redirected to its cart+ assert response.request['PATH_INFO'] == redirect_urldef test_view_checkout_summary_remove_voucher(