Skip to content

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

use urlparse

Maciek Jabłońskifb5590431c40
diff --git a/tests/test_checkout_integration.py b/tests/test_checkout_integration.py
index 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 Site
from django.core.urlresolvers import reverse
from 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 object
order_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_details
def 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, ca
data=payment_data)
assert payment_response.status_code == 302
- # Target page contains full URL with domain from Site object
order_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_details
def test_address_without_shipping(cart_with_item, client, monkeypatch): # pylint: disable=W0613
diff --git a/tests/utils.py b/tests/utils.py
index 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 cases
location = response['Location']
if location.startswith('http'):
- location = location.split('http://testserver')[1]
+ url = urlparse(location)
+ location = url.path
return location