forked from andres-torres-marroquin/django-dropbox
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from leonardoo/dev
Update to django 1.7 and test
- Loading branch information
Showing
29 changed files
with
382 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*.pyc | ||
django_dropbox.egg-info/ | ||
dist/ | ||
env/ | ||
venv/ | ||
bin/ | ||
lib/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: python | ||
python: 2.7 | ||
env: | ||
matrix: | ||
- TOX_ENV=py27-django14 | ||
- TOX_ENV=py27-django15 | ||
- TOX_ENV=py27-django16 | ||
- TOX_ENV=py27-django17 | ||
- TOX_ENV=py34-django15 | ||
- TOX_ENV=py34-django16 | ||
- TOX_ENV=py34-django17 | ||
- TOX_ENV=coverage | ||
global: | ||
- secure: ZdqsHM92b1pPklUT6S4j7mbnIQINOE5+QKOFoXqgq/N4lDHX8XvHywWDfn6iigr0R9Nj9F5RmzPB/EyaSbPb/RM14y1BlHPL4Jqwu83+JAyS6QxZqt1cAgrnG++rpJCnTT6tZTsiXgyWo6RCxMTQFAXQsvye6br0w5rLxP7Ymyg= | ||
- secure: XLLNIUgl5VsSy1w6i34z0Vo2NHRQcX9e8TS4Mg4Iq1fDT9WjLGG8tN2Nu4CFzrOK6PjCBFMTHgt88UJiQ45dxAzIFl+ApysqB+E2Z42r3HggiDn2iHfu8S/csSxgcFoI5qjyqeW3tDEOZfxtMZ18hqAPVFBlZ7QwmSSl7TeHb8k= | ||
- secure: ULa2n0dqO1/Vf8QpBXVz47XQ963LXEvD59/TmoxXffusMV47aASSv4j+kXU2+RwvzTDWO5k1afd5esebwGUiv78l/x5Ta4QiDpX6uxxPTQk/CGHEuUTMru7d/CYf3xPAB5Vu/mexaPHmPAT4sO3I9Sef6LIsFSNsXp/LkmbT3NQ= | ||
- secure: gXWm2BJJ7FoGMc09uzPUMpEeFCJMQE3awvJ9nnx6n1I4D7GZPyE7Ukm+o4o8DsjO/nBQzAqkMNJi4J2E4H0FvHnLHif8ktE0JATf3jYAHhOZO4NaY5aikSliMvH2a+JkfNZsUbUbq8zzcZMpyNX2O4N0cIZc9tplQznHD8RMrJU= | ||
install: | ||
- pip install tox | ||
script: | ||
- tox -e $TOX_ENV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
VERSION = (0, 0, 4) | ||
""" | ||
Django accounts management made easy. | ||
def get_version(): | ||
return '%s.%s.%s' % VERSION | ||
""" | ||
default_app_config = 'django_dropbox.apps.DjangoDropboxConfig' | ||
|
||
VERSION = (0, 0, 5) | ||
|
||
version = get_version() | ||
__version__ = '.'.join((str(each) for each in VERSION[:4])) | ||
|
||
def get_version(): | ||
""" | ||
Returns string with digit parts only as version. | ||
""" | ||
return '.'.join((str(each) for each in VERSION[:3])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DjangoDropboxConfig(AppConfig): | ||
name = 'django_dropbox' | ||
verbose_name = 'Django Dropbox' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
from io import BytesIO, StringIO | ||
|
||
from django.utils import six | ||
from django.utils.six.moves.urllib import parse as urlparse | ||
|
||
try: | ||
from django.utils.deconstruct import deconstructible | ||
except ImportError: # Django 1.7+ migrations | ||
deconstructible = lambda klass, *args, **kwargs: klass | ||
|
||
|
||
def getFile(content=None): | ||
if not content: | ||
return BytesIO() | ||
|
||
if six.PY3: | ||
stream_class = StringIO if isinstance(content, six.text_type) else BytesIO | ||
else: | ||
stream_class = BytesIO | ||
return stream_class(content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
import django_dropbox.storage | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TestDropbox', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('file_test', models.FileField(storage=django_dropbox.storage.DropboxStorage(location=b'/test/djangodropbox'), null=True, upload_to=b'.')), | ||
], | ||
options={ | ||
}, | ||
bases=(models.Model,), | ||
), | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
from django.db import models | ||
from django.utils.encoding import python_2_unicode_compatible | ||
from django_dropbox.storage import DropboxStorage | ||
from django.utils.encoding import force_text | ||
|
||
|
||
STORAGE = DropboxStorage(location="/test/djangodropbox") | ||
|
||
|
||
@python_2_unicode_compatible | ||
class TestDropbox(models.Model): | ||
""" | ||
Model for test django-dropbox storage | ||
""" | ||
file_test = models.FileField(upload_to=".",storage = STORAGE, null=True) | ||
|
||
def __str__(self): | ||
return os.path.basename(self.file_test.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import django | ||
|
||
if django.VERSION < (1, 6): | ||
from .test_models import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.core.files.base import ContentFile | ||
from django.test import TestCase | ||
from django_dropbox.storage import DropboxStorage | ||
from django.utils import six | ||
from django_dropbox.runtests.dbtest.models import TestDropbox | ||
|
||
class DropboxStorageTest(TestCase): | ||
|
||
def setUp(self): | ||
self.file_name = "test.txt" | ||
self.file_content = six.b("this is a test") | ||
|
||
def test_file_create_in_model(self): | ||
""" | ||
File must be create in model. | ||
""" | ||
model = TestDropbox() | ||
model.file_test.save(self.file_name, ContentFile(self.file_content)) | ||
self.assertEqual(model.__str__(),self.file_name) | ||
model.file_test.delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_dropbox.runtests.test_settings' | ||
|
||
import django | ||
from django.conf import settings | ||
from django.test.utils import get_runner | ||
|
||
if __name__ == "__main__": | ||
if django.VERSION >= (1, 7, 0): | ||
# starting from 1.7.0 we need to run setup() in order to populate | ||
# app config | ||
django.setup() | ||
if not settings.configured: | ||
settings.configure(myapp_defaults, DEBUG=True) | ||
|
||
TestRunner = get_runner(settings) | ||
test_runner = TestRunner() | ||
failures = test_runner.run_tests(["django_dropbox"]) | ||
sys.exit(failures) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import os | ||
import sys | ||
|
||
import django | ||
|
||
DEBUG = True | ||
TEMPLATE_DEBUG = DEBUG | ||
|
||
settings_dir = os.path.dirname(__file__) | ||
PROJECT_ROOT = os.path.abspath(settings_dir) | ||
|
||
ADMINS = ( | ||
# ('Your Name', '[email protected]'), | ||
) | ||
|
||
MANAGERS = ADMINS | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(PROJECT_ROOT, 'development.db'), | ||
} | ||
} | ||
|
||
# Internationalization | ||
TIME_ZONE = 'America/Chicago' | ||
LANGUAGE_CODE = 'en-us' | ||
|
||
SITE_ID = 1 | ||
|
||
# If you set this to False, Django will make some optimizations so as not | ||
# to load the internationalization machinery. | ||
USE_I18N = True | ||
|
||
# If you set this to False, Django will not format dates, numbers and | ||
# calendars according to the current locale. | ||
USE_L10N = True | ||
|
||
# If you set this to False, Django will not use timezone-aware datetimes. | ||
USE_TZ = True | ||
|
||
|
||
# List of finder classes that know how to find static files in | ||
# various locations. | ||
STATICFILES_FINDERS = ( | ||
'django.contrib.staticfiles.finders.FileSystemFinder', | ||
'django.contrib.staticfiles.finders.AppDirectoriesFinder', | ||
) | ||
|
||
# Make this unique, and don't share it with anybody. | ||
SECRET_KEY = '12345' | ||
|
||
# List of callables that know how to import templates from various sources. | ||
TEMPLATE_LOADERS = ( | ||
'django.template.loaders.filesystem.Loader', | ||
'django.template.loaders.app_directories.Loader', | ||
) | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
'django.middleware.common.CommonMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
'django.middleware.locale.LocaleMiddleware', | ||
) | ||
|
||
#ROOT_URLCONF = 'urls' | ||
#WSGI_APPLICATION = 'demo.wsgi.application' | ||
|
||
#TEMPLATE_DIRS = ( | ||
# os.path.join(PROJECT_ROOT, 'templates/'), | ||
#) | ||
|
||
INSTALLED_APPS = ( | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.sites', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'django.contrib.admin', | ||
"django_dropbox", | ||
"django_dropbox.runtests.dbtest", | ||
) | ||
|
||
LOGGING = { | ||
'version': 1, | ||
'disable_existing_loggers': False, | ||
'filters': { | ||
'require_debug_false': { | ||
'()': 'django.utils.log.RequireDebugFalse' | ||
} | ||
}, | ||
'handlers': { | ||
'mail_admins': { | ||
'level': 'ERROR', | ||
'filters': ['require_debug_false'], | ||
'class': 'django.utils.log.AdminEmailHandler' | ||
} | ||
}, | ||
'loggers': { | ||
'django.request': { | ||
'handlers': ['mail_admins'], | ||
'level': 'ERROR', | ||
'propagate': True, | ||
}, | ||
} | ||
} | ||
|
||
# Needed for Storage | ||
|
||
DROPBOX_CONSUMER_KEY = '9lyr7cjqblxb2kv' | ||
DROPBOX_CONSUMER_SECRET = '4saauuu6alx0iiz' | ||
DROPBOX_ACCESS_TOKEN = 'vkf07symi6iadqba' | ||
DROPBOX_ACCESS_TOKEN_SECRET = 'rz32iqtxsrfuwko' | ||
#DROPBOX_CONSUMER_KEY = os.environ['DROPBOX_CONSUMER_KEY'] | ||
#DROPBOX_CONSUMER_SECRET = os.environ['DROPBOX_CONSUMER_SECRET'] | ||
#DROPBOX_ACCESS_TOKEN = os.environ['DROPBOX_ACCESS_TOKEN'] | ||
#DROPBOX_ACCESS_TOKEN_SECRET = os.environ['DROPBOX_ACCESS_TOKEN_SECRET'] | ||
ACCESS_TYPE = 'app_folder' |
Oops, something went wrong.