diff --git a/.travis.yml b/.travis.yml index 8bf3b2d8..31de7437 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,26 @@ language: python python: - - 2.7 - - 3.4 - - 3.5 - - 3.6 +- 2.7 +- 3.4 +- 3.5 +- 3.6 env: - - DJANGO=1.10 - - DJANGO=1.11 - - DJANGO=2.0 +- DJANGO=1.9 +- DJANGO=1.10 +- DJANGO=1.11 +- DJANGO=2.0 +matrix: + exclude: + - python: 2.7 + env: DJANGO=2.0 install: - - pip install -q Django~=$DJANGO.0 +- pip install -q Django~=$DJANGO.0 script: - - python runtests.py +- python runtests.py +deploy: + provider: pypi + user: bradleyg + on: + tags: true + password: + secure: a+Xq1e2yuTNtjcJ5wJ5oQxsfx/lqwYD7dbFEqdoazpkflZ8UA9AErgL2quAbo0RIRKFDBXwRNUspRtQdQ6TClKxgzsaa4AQEPWxYxx353kYMdhPjXe0/ib1rWJ0eefs/RDu0mndpQu/slNjxzV351QXPoPKo9tHgnLHWoNzYAzs= diff --git a/runtests.py b/runtests.py index 18a05a01..490c3c5a 100644 --- a/runtests.py +++ b/runtests.py @@ -25,6 +25,10 @@ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ), + MIDDLEWARE_CLASSES=( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + ), TEMPLATES=[ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', diff --git a/s3direct/tests.py b/s3direct/tests.py index 682d2533..cc27e531 100644 --- a/s3direct/tests.py +++ b/s3direct/tests.py @@ -4,9 +4,12 @@ from django.conf import settings from django.contrib.auth.models import User -from django.urls import resolve, reverse from django.test import TestCase from django.test.utils import override_settings +try: + from django.urls import resolve, reverse +except ImportError: + from django.core.urlresolvers import resolve, reverse from s3direct import widgets @@ -39,13 +42,18 @@ u'server_side_encryption': None, } +def is_authenticated(user): + if callable(user.is_authenticated): # Django =< 1.9 + return user.is_authenticated() + return user.is_authenticated + TEST_DESTINATIONS = { 'misc': {'key': lambda original_filename: 'images/unique.jpg'}, 'files': {'key': '/', 'auth': lambda u: u.is_staff}, 'imgs': {'key': 'uploads/imgs', 'allowed': ['image/jpeg', 'image/png']}, 'thumbs': {'key': 'uploads/thumbs', 'allowed': ['image/jpeg'], 'content_length_range': (1000, 50000)}, - 'vids': {'key': 'uploads/vids', 'auth': lambda u: u.is_authenticated, 'allowed': ['video/mp4']}, - 'cached': {'key': 'uploads/vids', 'auth': lambda u: u.is_authenticated, 'allowed': '*', + 'vids': {'key': 'uploads/vids', 'auth': is_authenticated, 'allowed': ['video/mp4']}, + 'cached': {'key': 'uploads/vids', 'auth': is_authenticated, 'allowed': '*', 'acl': 'authenticated-read', 'bucket': 'astoragebucketname', 'cache_control': 'max-age=2592000', 'content_disposition': 'attachment', 'server_side_encryption': 'AES256'}, 'accidental-leading-slash': {'key': '/directory/leading'},