Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
use urlparse
Maciek Jabłońskifb5590431c40
diff --git a/tests/test_checkout_integration.py b/tests/test_checkout_integration.pyindex d0b5f2652a..7e86027dde 100644--- a/tests/test_checkout_integration.py+++ b/tests/test_checkout_integration.py@@ -1,4 +1,3 @@-from django.contrib.sites.models import Sitefrom django.core.urlresolvers import reversefrom tests.utils import get_redirect_location@@ -67,11 +66,8 @@ def test_checkout_flow(cart_with_item, product_in_stock, client, shipping_method'verification_result': 'waiting'}payment_response = client.post(payment_page_url, data=payment_data)assert payment_response.status_code == 302- # Target page contains full URL with domain from Site objectorder_details = reverse('order:details', kwargs={'token': order.token})- site = Site.objects.get_current()- expected_url = 'http://%s%s' % (site, order_details)- assert payment_response['Location'] == expected_url+ assert get_redirect_location(payment_response) == order_detailsdef test_checkout_flow_authenticated_user(authorized_client, billing_address, cart_with_item,@@ -126,11 +122,8 @@ def test_checkout_flow_authenticated_user(authorized_client, billing_address, cadata=payment_data)assert payment_response.status_code == 302- # Target page contains full URL with domain from Site objectorder_details = reverse('order:details', kwargs={'token': order.token})- site = Site.objects.get_current()- expected_url = 'http://%s%s' % (site, order_details)- assert payment_response['Location'] == expected_url+ assert get_redirect_location(payment_response) == order_detailsdef test_address_without_shipping(cart_with_item, client, monkeypatch): # pylint: disable=W0613diff --git a/tests/utils.py b/tests/utils.pyindex 83b50dd9d0..16ebeb3498 100644--- a/tests/utils.py+++ b/tests/utils.py@@ -1,6 +1,10 @@+from urlparse import urlparse++def get_redirect_location(response):# Due to Django 1.8 compatibility, we have to handle both caseslocation = response['Location']if location.startswith('http'):- location = location.split('http://testserver')[1]+ url = urlparse(location)+ location = url.pathreturn location