Skip to content

Commit

Permalink
Add testing framework, no tests written yet
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed May 9, 2017
1 parent ea33f2f commit 7d62a3b
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source = private_storage
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
sudo: false
language: python
python:
- '2.7'
- '3.6'
env:
- DJANGO="django>=1.8.0,<1.9.0"
- DJANGO="django>=1.9.0,<1.10.0"
- DJANGO="django>=1.10.0,<1.11.0"
- DJANGO="django>=1.11.0,<1.12.0"
before_install:
- pip install codecov
install:
- travis_retry pip install $DJANGO django-storages boto3 -e .
script:
- coverage run --rcfile=.coveragerc runtests.py
after_success:
- codecov
branches:
only:
- master
notifications:
email:
recipients:
- [email protected]
on_success: never
on_failure: always
slack:
secure: WWNa4MHf50AOybB+XW9UKXCk/9Q8r++Jc4xTdEib43rj4odH9wxIaTRrzAbbpo3EO2gYuLgq6mMbaIZPD5l2UmgSnyuIbeYAAKIQblT+8XMamtXwnSS5j9vfBXYdj54rTlh+jKwEMW/JiQKl+SQpfQ2v1NMvYO63m89Ev9vXvcU=
on_success: never
on_failure: always
Empty file.
12 changes: 12 additions & 0 deletions private_storage/tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Most pathetic test case ever, only see if all files are importable.
# TODO: write real tests.
import private_storage
import private_storage.storage.files
import private_storage.storage.s3boto3
import private_storage.appconfig
import private_storage.fields
import private_storage.models
import private_storage.permissions
import private_storage.servers
import private_storage.urls
import private_storage.views
71 changes: 71 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python
import sys
import django
from django.conf import settings, global_settings as default_settings
from django.core.management import execute_from_command_line
from os import path

if not settings.configured:
module_root = path.dirname(path.realpath(__file__))

sys.path.insert(0, path.join(module_root, 'example'))

if django.VERSION >= (1, 8):
template_settings = dict(
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (),
'DEBUG': True,
'OPTIONS': {
'loaders': (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
'context_processors': (
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
),
},
},
]
)
else:
template_settings = dict(
TEMPLATE_LOADERS = (
'django.template.loaders.app_directories.Loader',
'django.template.loaders.filesystem.Loader',
),
TEMPLATE_CONTEXT_PROCESSORS = list(default_settings.TEMPLATE_CONTEXT_PROCESSORS) + [
'django.core.context_processors.request',
],
TEMPLATE_DEBUG = True,
)

settings.configure(
DEBUG = False, # will be False anyway by DjangoTestRunner.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
INSTALLED_APPS = (
'private_storage',
),
TEST_RUNNER = 'django.test.runner.DiscoverRunner',
AWS_PRIVATE_STORAGE_BUCKET_NAME='foobar',
**template_settings
)


def runtests():
argv = sys.argv[:1] + ['test', 'private_storage'] + sys.argv[1:]
execute_from_command_line(argv)

if __name__ == '__main__':
runtests()
28 changes: 28 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tox]
envlist=
py27-django{18,19,110,111},
py36-django{18,19,110,111},
# py36-django-dev,
coverage,

[testenv]
deps =
django-storages
boto3
django18: Django >= 1.8,<1.9
django19: Django >= 1.9,<1.10
django110: Django >= 1.10,<1.11
django111: Django >= 1.11,<1.12
django-dev: https://github.com/django/django/tarball/master
commands=
python runtests.py

[testenv:coverage]
basepython=python3.6
deps=
django==1.11
coverage
commands=
coverage erase
coverage run --rcfile=.coveragerc runtests.py
coverage report

0 comments on commit 7d62a3b

Please sign in to comment.