Skip to content

Commit

Permalink
Merge pull request #10 from jamstooks/1.8-update
Browse files Browse the repository at this point in the history
Updated tests to pass for 1.8; Migrated to travis for django versions;
  • Loading branch information
jamstooks committed Sep 1, 2015
2 parents 5df56d9 + e2b078a commit b5d4f2c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 26 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

2 changes: 2 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
boto
django-storages
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
36 changes: 21 additions & 15 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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
Expand All @@ -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()
main()

0 comments on commit b5d4f2c

Please sign in to comment.