Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix Django 1.8 compatibility in tests
Artur Smętcca9116d7c52
diff --git a/.travis.yml b/.travis.ymlindex 09dfed6761..010917e6d3 100644--- a/.travis.yml+++ b/.travis.yml@@ -13,7 +13,7 @@ script:- toxenv:global:- - SECRET_KEY=irrelevant+ - DJANGO_SETTINGS_MODULE=saleor.test_settingsmatrix:- TOXENV=py27-django18- TOXENV=py27-django19diff --git a/saleor/checkout/test_checkout_integration.py b/saleor/checkout/test_checkout_integration.pyindex 44e593aa06..da79dd8635 100644--- a/saleor/checkout/test_checkout_integration.py+++ b/saleor/checkout/test_checkout_integration.py@@ -9,6 +9,15 @@ from ..order import Status as OrderStatusfrom ..order.models import Order+def assert_redirect(response, expected_url):+ assert response.status_code == 302+ # 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]+ assert location == expected_url++def test_checkout_flow(product, variant, client):"""Basic test case that confirms if core checkout flow works@@ -39,9 +48,8 @@ def test_checkout_flow(product, variant, client):assert cart_lines[0]['product'] == variant# Enter checkoutcheckout_index = client.get(urls['checkout_index'])- assert checkout_index.status_code == 302# Checkout index redirects directly to shipping address step- assert checkout_index['Location'] == urls['checkout_shipping_address']+ assert_redirect(checkout_index, urls['checkout_shipping_address'])shipping_address = client.get(urls['checkout_shipping_address'])assert shipping_address.status_code == 200# Enter shipping address data@@ -59,23 +67,20 @@ def test_checkout_flow(product, variant, client):shipping_response = client.post(urls['checkout_shipping_address'], data=shipping_data)# Select shipping method- assert shipping_response.status_code == 302- assert shipping_response['Location'] == urls['checkout_shipping_method']+ assert_redirect(shipping_response, urls['checkout_shipping_method'])shipping_method_page = client.get(urls['checkout_shipping_method'])assert shipping_method_page.status_code == 200# Redirect to summary after shipping method selectionshipping_method_response = client.post(urls['checkout_shipping_method'], data={'method': shipping_method.pk})- assert shipping_method_response.status_code == 302- assert shipping_method_response['Location'] == urls['checkout_summary']+ assert_redirect(shipping_method_response, urls['checkout_summary'])# Summary page asks for Billing address, default is the same as shippingsummary_response = client.post(urls['checkout_summary'],data={'address': 'shipping_address'})- assert summary_response.status_code == 302# After summary step, order is created and it waits for paymentorder = Order.objects.latest('pk')order_payment_url = reverse('order:payment', kwargs={'token': order.token})- assert summary_response['Location'] == order_payment_url+ assert_redirect(summary_response, order_payment_url)payment_method_page = client.get(order_payment_url)assert payment_method_page.status_code == 200# Select payment methoddiff --git a/tox.ini b/tox.iniindex 92d34d52e5..e83fb80646 100644--- a/tox.ini+++ b/tox.ini@@ -3,7 +3,7 @@ envlist = py{27,34,35}-django{18,19,110,_master}skipsdist = True[testenv]-passenv = SECRET_KEY+passenv = DJANGO_SETTINGS_MODULEdeps =-rrequirements.txtpytest-cov