Skip to content

Commit

Permalink
add testing
Browse files Browse the repository at this point in the history
add testing for travis, remove empty files and django_dropbox_project
  • Loading branch information
leonardoo committed Dec 29, 2014
1 parent 8645648 commit 36b402f
Show file tree
Hide file tree
Showing 20 changed files with 104 additions and 234 deletions.
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: python
python: 2.7
env:
- TOX_ENV=py26-django14
- TOX_ENV=py26-django15
- TOX_ENV=py26-django16
- 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: J/5lMe5kssOijDOrxivPocuPcwaiOr0VxGxmMgKkLYHOVCUujVCNO32Ze/70KXmvyzRZx7K9yeER0qP1AcY/Zg8wTJi58nefbK9lnbu6/K6OQovj4fxUAZtZkB7X4CBvrUYKCeeVd+zJw31WC2v6Vtp3mh4irIm/TPIpeyoegmQ=
- secure: ilN2b4RV4+//9N2DnFGh/hfDQS9ahBX6mY+OwWX72eqRlUyvt+eYGgljscWKEtDdVoA0SOSbZ7ghS2F9R+JsglYuyE//cb6DMsFa3+CW3I/Jl59nqKIgJkrmC1CrVSWmG/uISE0prITpIBH/3P5rT4EvqFQIfQ1WItAwtAmZKak=
- secure: j9R74s5cwHWoGgQlIVqRj56gD+16wzGI7XIPFJ11yWDlgrftR0vkgiPlfgK5KKga4LOJBI2m92zgzr2OC9pgkvYjFR+i206F2cN2KbH2P8rFZtECp+o2uHBIhuZ8xOvw4TbxUNRd/ej6E4eKNcRvavwzfEwWO4C4v6FhC2rr5xk=
- secure: NHsCChxiQJw07EUsqs2mtmmppApN8DLAB79JVeKoptQaxqxtzinL7QXxugAc0BNxvC3iCtTY5/232RyRn9dNNzY5Jq/b5YIsJJTMtAMTtY5xuJn8TTYV+TB5G31k9fnAAiqhdmdo7m7E6OSDxIYv44k147W43T0+nLlxCLlADew=
install:
- pip install tox
script:
- tox -e $TOX_ENV
6 changes: 6 additions & 0 deletions django_dropbox/comp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.six import BytesIO
try:
from django.utils.deconstruct import deconstructible
except ImportError: # Django 1.7+ migrations
deconstructible = lambda klass, *args, **kwargs: klass
9 changes: 5 additions & 4 deletions django_dropbox/management/commands/get_dropbox_token.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from django.core.management.base import NoArgsCommand
from dropbox import rest, session
from django_dropbox.settings import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TYPE
Expand All @@ -9,12 +10,12 @@ def handle_noargs(self, *args, **options):
request_token = sess.obtain_request_token()

url = sess.build_authorize_url(request_token)
print "Url:", url
print "Please visit this website and press the 'Allow' button, then hit 'Enter' here."
print("Url:", url)
print("Please visit this website and press the 'Allow' button, then hit 'Enter' here.")
raw_input()

# This will fail if the user didn't visit the above URL and hit 'Allow'
access_token = sess.obtain_access_token(request_token)

print "DROPBOX_ACCESS_TOKEN = '%s'" % access_token.key
print "DROPBOX_ACCESS_TOKEN_SECRET = '%s'" % access_token.secret
print("DROPBOX_ACCESS_TOKEN = '%s'" % access_token.key)
print("DROPBOX_ACCESS_TOKEN_SECRET = '%s'" % access_token.secret)
Empty file removed django_dropbox/models.py
Empty file.
File renamed without changes.
18 changes: 18 additions & 0 deletions django_dropbox/runtest/runtest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
import os
import sys

import django
from django.conf import settings
from django.test.utils import get_runner

if __name__ == "__main__":
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
if django.VERSION >= (1, 7, 0):
# starting from 1.7.0 we need to run setup() in order to populate
# app config
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(["django_dropbox"])
sys.exit(failures)
10 changes: 10 additions & 0 deletions django_dropbox/runtest/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

INSTALLED_APPS = [
"django_dropbox",
]

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']
12 changes: 4 additions & 8 deletions django_dropbox/storage.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import errno
import os.path
import re
import urlparse
import urllib
import itertools
import platform

try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
from dropbox.session import DropboxSession
from dropbox.client import DropboxClient
from dropbox.rest import ErrorResponse
Expand All @@ -18,6 +12,8 @@
from django.core.files.storage import Storage
from django.utils.encoding import filepath_to_uri


from .compat import urlparse, BytesIO
from .settings import (CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TYPE,
Expand Down Expand Up @@ -141,7 +137,7 @@ def __init__(self, name, storage, mode):
self._storage = storage
self._mode = mode
self._is_dirty = False
self.file = StringIO()
self.file = BytesIO()
self._is_read = False

@property
Expand All @@ -159,7 +155,7 @@ def read(self, num_bytes=None):
def write(self, content):
if 'w' not in self._mode:
raise AttributeError("File was opened for read-only access.")
self.file = StringIO(content)
self.file = BytesIO(content)
self._is_dirty = True
self._is_read = True

Expand Down
1 change: 1 addition & 0 deletions django_dropbox/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ def test_file_size(self):

self.storage.delete('storage_test_size')
self.assertFalse(self.storage.exists('storage_test_size'))

Empty file removed django_dropbox/views.py
Empty file.
1 change: 0 additions & 1 deletion django_dropbox_project/django_dropbox

This file was deleted.

Empty file.
13 changes: 0 additions & 13 deletions django_dropbox_project/dropbox_testing/admin.py

This file was deleted.

8 changes: 0 additions & 8 deletions django_dropbox_project/dropbox_testing/models.py

This file was deleted.

16 changes: 0 additions & 16 deletions django_dropbox_project/dropbox_testing/tests.py

This file was deleted.

1 change: 0 additions & 1 deletion django_dropbox_project/dropbox_testing/views.py

This file was deleted.

14 changes: 0 additions & 14 deletions django_dropbox_project/manage.py

This file was deleted.

152 changes: 0 additions & 152 deletions django_dropbox_project/settings.py

This file was deleted.

17 changes: 0 additions & 17 deletions django_dropbox_project/urls.py

This file was deleted.

Loading

0 comments on commit 36b402f

Please sign in to comment.