diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..003dd69 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: python +python: + - "2.7" + +env: + - DJANGO_VERSION=1.4.22 + - DJANGO_VERSION=1.7.10 + - DJANGO_VERSION=1.8.4 + +install: + - pip install -q Django==$DJANGO_VERSION + - pip install -r requirements_test.txt + +script: python tests.py diff --git a/README.md b/README.md index a9a9903..63f0565 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ django-s3-folder-storage ======================== -[![Latest PyPI version](https://pypip.in/v/django-s3-folder-storage/badge.png)](https://crate.io/packages/django-s3-folder-storage/) -[![Number of PyPI downloads](https://pypip.in/d/django-s3-folder-storage/badge.png)](https://crate.io/packages/django-s3-folder-storage/) -[![Build Status](https://drone.io/github.com/jamstooks/django-s3-folder-storage/status.png)](https://drone.io/github.com/jamstooks/django-s3-folder-storage/latest) +[![Build Status](https://travis-ci.org/jamstooks/django-s3-folder-storage.svg)](https://travis-ci.org/jamstooks/django-s3-folder-storage) [![Code Climate](https://codeclimate.com/github/jamstooks/django-s3-folder-storage/badges/gpa.svg)](https://codeclimate.com/github/jamstooks/django-s3-folder-storage) @@ -43,7 +41,7 @@ Here's an example: AWS_ACCESS_KEY_ID = {{ your key id here }} AWS_SECRET_ACCESS_KEY = {{ your secret key here }} AWS_STORAGE_BUCKET_NAME = {{ your bucket name here }} - + MEDIA_ROOT = '/%s/' % DEFAULT_S3_PATH MEDIA_URL = '//s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME STATIC_ROOT = "/%s/" % STATIC_S3_PATH @@ -63,11 +61,11 @@ As a first step, I recommend trying to get the `collectstatic` management command working within your project: python manage.py collectstatic - + You can also run the tests: python manage.py test s3_folder_storage - + to confirm that files are being written to S3 Contributing diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index f720c25..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Django==1.6 -boto==2.18.0 -django-storages==1.1.8 \ No newline at end of file diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 0000000..4e6c8ae --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1,2 @@ +boto +django-storages diff --git a/setup.py b/setup.py index e740963..9cb2949 100644 --- a/setup.py +++ b/setup.py @@ -2,12 +2,14 @@ from setuptools import setup, find_packages import os + # Utility function to read README file def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() -setup(name='django-s3-folder-storage', - version='0.2', +setup( + name='django-s3-folder-storage', + version='0.3', description="Quick extension of django-storages' S3BotoStorage to allow separate folders for uploaded and static media within an S3 bucket.", author='Benjamin W Stookey', author_email='ben.stookey@gmail.com', diff --git a/tests.py b/tests.py index e581915..f8afcc0 100644 --- a/tests.py +++ b/tests.py @@ -4,10 +4,11 @@ BASE_PATH = os.path.dirname(__file__) + def main(): """ Standalone django model test with a 'memory-only-django-installation'. - You can play with a django model without a complete django app installation. + You can play with a django model without a complete django app installation http://www.djangosnippets.org/snippets/1044/ """ sys.exc_clear() @@ -21,7 +22,7 @@ def main(): 'django.contrib.contenttypes', 's3_folder_storage', ) - if django.VERSION > (1,2): + if django.VERSION > (1, 2): global_settings.DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', @@ -36,7 +37,6 @@ def main(): global_settings.DATABASE_ENGINE = "sqlite3" global_settings.DATABASE_NAME = ":memory:" - global_settings.ROOT_URLCONF='beproud.django.authutils.tests.test_urls' global_settings.MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -45,24 +45,26 @@ def main(): 'django.contrib.messages.middleware.MessageMiddleware', 'beproud.django.authutils.middleware.AuthMiddleware', ) - + # custom settings for tests - global_settings.DEFAULT_FILE_STORAGE = 's3_folder_storage.s3.DefaultStorage' global_settings.DEFAULT_S3_PATH = "media" global_settings.STATICFILES_STORAGE = 's3_folder_storage.s3.StaticStorage' global_settings.STATIC_S3_PATH = "static" # requires some envifonment variables - global_settings.AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID', None) - global_settings.AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY', None) - global_settings.AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME', None) + global_settings.AWS_ACCESS_KEY_ID = os.environ.get( + 'AWS_ACCESS_KEY_ID', None) + global_settings.AWS_SECRET_ACCESS_KEY = os.environ.get( + 'AWS_SECRET_ACCESS_KEY', None) + global_settings.AWS_STORAGE_BUCKET_NAME = os.environ.get( + 'AWS_STORAGE_BUCKET_NAME', None) global_settings.MEDIA_ROOT = '/%s/' % global_settings.DEFAULT_S3_PATH global_settings.MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % global_settings.AWS_STORAGE_BUCKET_NAME global_settings.STATIC_ROOT = "/%s/" % global_settings.STATIC_S3_PATH global_settings.STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % global_settings.AWS_STORAGE_BUCKET_NAME - global_settings.ADMIN_MEDIA_PREFIX = global_settings.STATIC_URL + 'admin/' + global_settings.ADMIN_MEDIA_PREFIX = global_settings.STATIC_URL + 'admin/' # global_settings.DEFAULT_FILE_STORAGE = 'backends.s3boto.S3BotoStorage' # global_settings.AWS_IS_GZIPPED = True @@ -71,14 +73,18 @@ def main(): from django.test.utils import get_runner test_runner = get_runner(global_settings) - # import pdb; pdb.set_trace() - - if django.VERSION > (1,2): + if django.VERSION > (1, 7): + print "running 1.7+ tests" + django.setup() + from django.test.runner import DiscoverRunner + test_runner = DiscoverRunner() + failures = test_runner.run_tests(['s3_folder_storage', ]) + elif django.VERSION > (1, 2): test_runner = test_runner() - failures = test_runner.run_tests(['s3_folder_storage',]) + failures = test_runner.run_tests(['s3_folder_storage', ]) else: - failures = test_runner(['s3_folder_storage',], verbosity=1) + failures = test_runner(['s3_folder_storage', ], verbosity=1) sys.exit(failures) if __name__ == '__main__': - main() \ No newline at end of file + main()