Skip to content

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

Reorganize tests and dependencies

Patryk Zawadzki46d06385f883
diff --git a/.travis.yml b/.travis.yml
index d4377970a7..40d66a55f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,8 @@ language: python
python:
- 2.6
- 2.7
+ - 3.2
+ - 3.3
install:
- python setup.py install
script:
diff --git a/setup.py b/setup.py
index 44eaa812fe..6cf262d578 100755
--- a/setup.py
+++ b/setup.py
@@ -23,10 +23,10 @@ setup(
include_package_data=True,
install_requires=[
'Django>=1.5',
- 'django-images>=0.3.1,<-0.4a0',
+ 'django-images>=0.3.2,<-0.4a0',
'django-mptt>=0.5',
- 'django-payments>=0.3,<0.4a0',
- 'django-prices>=0.2,<0.3a0',
+ 'django-payments>=0.3.3,<0.4a0',
+ 'django-prices>=0.2.4,<0.3a0',
'prices>=0.4.2,<0.5a0',
'satchless>=1.0.4,<1.1a0',
'South>=0.7.6',
diff --git a/shop/checkout/forms.py b/shop/checkout/forms.py
index 120ca7e642..cde1b8dd79 100644
--- a/shop/checkout/forms.py
+++ b/shop/checkout/forms.py
@@ -2,6 +2,7 @@ from django import forms
from django.contrib.auth.models import AnonymousUser
from django.core import validators
from django.core.exceptions import ValidationError
+from django.utils.encoding import smart_text
from ..order.models import DigitalDeliveryGroup
from ..userprofile.forms import AddressForm
@@ -24,7 +25,6 @@ class DigitalDeliveryForm(forms.ModelForm):
email = self.fields['email']
email.required = True
if user.is_authenticated():
- print 'asd'
email.initial = user.email
@@ -32,7 +32,7 @@ class DeliveryField(forms.ChoiceField):
def __init__(self, methods, *args, **kwargs):
self.methods = list(methods)
- choices = [(index, unicode(method)) for index, method in
+ choices = [(index, smart_text(method)) for index, method in
enumerate(self.methods)]
super(DeliveryField, self).__init__(choices, *args, **kwargs)
diff --git a/shop/communication/tests.py b/shop/communication/tests.py
index 3c8b4430a6..c1f6b32c24 100644
--- a/shop/communication/tests.py
+++ b/shop/communication/tests.py
@@ -1,6 +1,7 @@
+from unittest import TestCase
+
from django.template.loader_tags import BlockNode
from mock import Mock, patch, sentinel
-from unittest2 import TestCase
from .mail import SUBJECT, TEXT, HTML, send_email, render_blocks
diff --git a/shop/core/tests/__init__.py b/shop/core/tests.py
similarity index 96%
rename from shop/core/tests/__init__.py
rename to shop/core/tests.py
index 398d1d3f48..cedf5945b4 100644
--- a/shop/core/tests/__init__.py
+++ b/shop/core/tests.py
@@ -1,9 +1,10 @@
-from ..utils import BaseStep
from django.template.response import TemplateResponse
from django.test import TestCase
from mock import MagicMock
from satchless.process import InvalidData
+from .utils import BaseStep
+
class SimpleStep(BaseStep):
diff --git a/shop/core/utils/__init__.py b/shop/core/utils/__init__.py
index f72790b6be..7415618945 100644
--- a/shop/core/utils/__init__.py
+++ b/shop/core/utils/__init__.py
@@ -7,7 +7,10 @@ from django.http.request import absolute_http_url_re
from django.template.response import TemplateResponse
from django.utils.encoding import iri_to_uri
from satchless.process import InvalidData, Step
-from urlparse import urljoin
+try:
+ from urllib.parse import urljoin
+except ImportError:
+ from urlparse import urljoin
__all__ = ['BaseStep', 'CategoryChoiceField', 'build_absolute_uri']
diff --git a/shop/registration/tests.py b/shop/registration/tests.py
index 642b9b63ed..ed3d58b15d 100644
--- a/shop/registration/tests.py
+++ b/shop/registration/tests.py
@@ -1,9 +1,9 @@
+from unittest import TestCase
+
from django.contrib.auth import get_user_model
from django.core.urlresolvers import resolve
-
from mock import call, Mock, MagicMock, patch, sentinel
from purl import URL
-from unittest2 import TestCase
from .forms import RegisterOrResetPasswordForm, OAuth2CallbackForm
from .utils import (
diff --git a/shop/registration/utils.py b/shop/registration/utils.py
index f40591a331..f569b9ed8e 100644
--- a/shop/registration/utils.py
+++ b/shop/registration/utils.py
@@ -1,12 +1,16 @@
+import logging
+try:
+ from urllib.parse import parse_qs, urlencode, urljoin, urlunparse
+except ImportError:
+ from urllib import urlencode
+ from urlparse import parse_qs, urljoin, urlunparse
+
from django.core.urlresolvers import reverse
from django.conf import settings
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext_lazy as _
-
-import logging
import requests
-import urllib
-import urlparse
+
GOOGLE, FACEBOOK = 'google', 'facebook'
JSON_MIME_TYPE = 'application/json'
@@ -20,7 +24,7 @@ def get_local_host(request):
def url(scheme='', host='', path='', params='', query='', fragment=''):
- return urlparse.urlunparse((scheme, host, path, params, query, fragment))
+ return urlunparse((scheme, host, path, params, query, fragment))
def get_client_class_for_service(service):
@@ -39,9 +43,9 @@ def parse_response(response):
if JSON_MIME_TYPE in response.headers['Content-Type']:
return response.json()
else:
- content = urlparse.parse_qs(response.text)
+ content = parse_qs(response.text)
content = dict((x, y[0] if len(y) == 1 else y)
- for x, y in content.iteritems())
+ for x, y in content.items())
return content
@@ -80,15 +84,15 @@ class OAuth2Client(object):
def get_redirect_uri(self):
kwargs = {'service': self.service}
path = reverse('registration:oauth_callback', kwargs=kwargs)
- return urlparse.urljoin(self.local_host, path)
+ return urljoin(self.local_host, path)
def get_login_uri(self):
data = {'response_type': 'code',
'scope': self.scope,
'redirect_uri': self.get_redirect_uri(),
'client_id': self.client_id}
- query = urllib.urlencode(data)
- return urlparse.urljoin(self.auth_uri, url(query=query))
+ query = urlencode(data)
+ return urljoin(self.auth_uri, url(query=query))
def get_access_token(self, code):
data = {'grant_type': 'authorization_code',
diff --git a/shop/registration/views.py b/shop/registration/views.py
index 977fdc7096..edec40b5c9 100644
--- a/shop/registration/views.py
+++ b/shop/registration/views.py
@@ -1,15 +1,16 @@
-from urllib import urlencode
+try:
+ from urllib.parse import urlencode
+except ImportError:
+ from urllib import urlencode
from django.conf import settings
from django.contrib import messages
-from django.contrib.auth import (
- login as auth_login,
- logout as auth_logout,
- get_user_model)
+from django.contrib.auth import (login as auth_login,
+ logout as auth_logout,
+ get_user_model)
from django.contrib.auth.decorators import login_required
-from django.contrib.auth.views import (
- login as django_login_view,
- password_change)
+from django.contrib.auth.views import (login as django_login_view,
+ password_change)
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.template.response import TemplateResponse
@@ -46,7 +47,7 @@ def oauth_callback(request, service):
try:
user = form.get_authenticated_user()
return _login_user(request, user)
- except ValueError, e:
+ except ValueError as e:
messages.error(request, unicode(e))
else:
for _field, errors in form.errors.items():