Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Add support for Django 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jpadilla committed Sep 3, 2014
1 parent 71ec0df commit 40bd310
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ python:
- "3.4"

env:
- DJANGO="django==1.7"
- DJANGO="django==1.6.5"
- DJANGO="django==1.5.8"
- DJANGO="django==1.4.13"
Expand All @@ -26,6 +27,8 @@ script:

matrix:
exclude:
- python: "2.6"
env: DJANGO="django==1.7"
- python: "3.2"
env: DJANGO="django==1.4.13"
- python: "3.3"
Expand Down
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import django


def pytest_configure():
from django.conf import settings

Expand Down Expand Up @@ -32,7 +35,6 @@ def pytest_configure():
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tests',
),
PASSWORD_HASHERS=(
'django.contrib.auth.hashers.SHA1PasswordHasher',
Expand Down Expand Up @@ -64,8 +66,10 @@ def pytest_configure():
'provider.oauth2',
)

if django.VERSION >= (1, 5):
settings.INSTALLED_APPS += ('tests',)

try:
import django
django.setup()
except AttributeError:
pass
12 changes: 10 additions & 2 deletions tests/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from django.contrib.auth.models import User
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager


class CustomUser(User):
class CustomUser(AbstractBaseUser):
email = models.EmailField(max_length=255, unique=True)

objects = BaseUserManager()

USERNAME_FIELD = 'email'

class Meta:
app_label = 'tests'
5 changes: 2 additions & 3 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'tests',
)

# OAuth is optional and won't work if there is no oauth_provider & oauth2
Expand Down Expand Up @@ -134,5 +133,5 @@

import django

if django.VERSION < (1, 3):
INSTALLED_APPS += ('staticfiles',)
if django.VERSION >= (1, 5):
INSTALLED_APPS += ('tests',)
4 changes: 2 additions & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from rest_framework_jwt import utils
from rest_framework_jwt.settings import api_settings, DEFAULTS

from .models import CustomUser


NO_CUSTOM_USER_MODEL = 'Custom User Model only supported after Django 1.5'

Expand Down Expand Up @@ -123,6 +121,8 @@ class CustomUserObtainJSONWebTokenTests(TestCase):
urls = 'tests.test_views'

def setUp(self):
from .models import CustomUser

self.email = '[email protected]'
self.password = 'password'
user = CustomUser.objects.create(email=self.email)
Expand Down
29 changes: 29 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
downloadcache = {toxworkdir}/cache/
envlist =
py3.4-django1.7,py3.3-django1.7,py3.2-django1.7,py2.7-django1.7,
py3.4-django1.6,py3.3-django1.6,py3.2-django1.6,py2.7-django1.6,py2.6-django1.6,
py3.4-django1.5,py3.3-django1.5,py3.2-django1.5,py2.7-django1.5,py2.6-django1.5,
py2.7-django1.4,py2.6-django1.4
Expand All @@ -14,6 +15,34 @@ deps = pytest==2.5.2
flake8==2.2.2
commands = ./runtests.py --lintonly

[testenv:py3.4-django1.7]
basepython = python3.4
deps = Django==1.7
djangorestframework>=2.3.11
PyJWT>=0.1.8
pytest-django==2.6.1

[testenv:py3.3-django1.7]
basepython = python3.3
deps = Django==1.7
djangorestframework>=2.3.11
PyJWT>=0.1.8
pytest-django==2.6.1

[testenv:py3.2-django1.7]
basepython = python3.2
deps = Django==1.7
djangorestframework>=2.3.11
PyJWT>=0.1.8
pytest-django==2.6.1

[testenv:py2.7-django1.7]
basepython = python2.7
deps = Django==1.7
djangorestframework>=2.3.11
PyJWT>=0.1.8
pytest-django==2.6.1

[testenv:py3.4-django1.6]
basepython = python3.4
deps = Django==1.6.3
Expand Down

0 comments on commit 40bd310

Please sign in to comment.