Skip to content

Commit

Permalink
Created full test project.
Browse files Browse the repository at this point in the history
This replaces the simple settings-only approach to testing.
  • Loading branch information
yellowcap committed Jun 6, 2017
1 parent ca144e3 commit e4c0dc4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ python:
sudo: false

env:
- DB_NAME=raster_test PYTHONPATH=$PYTHONPATH:$PWD DJANGO_SETTINGS_MODULE=settings USE_NOSE=True
- DB_NAME=raster_test PYTHONPATH=$PYTHONPATH:$PWD DJANGO_SETTINGS_MODULE=tests.testproj.settings

before_script:
- psql -c 'create database raster_test' -U postgres
- psql -c 'create extension postgis' -U postgres -d raster_test

install:
- pip install django==1.11.1
- pip install -e .
- pip install psycopg2==2.7.1
- pip install celery==4.0.2
- pip install numpy
- pip install Pillow==4.1.1
- pip install django-colorful==1.0.1
- pip install pyparsing==2.2.0
- pip install flake8==3.3.0
- pip install isort==4.2.2
- pip install coverage==4.4
Expand Down
7 changes: 7 additions & 0 deletions tests/testproj/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import absolute_import, unicode_literals

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

__all__ = ['celery_app']
26 changes: 26 additions & 0 deletions tests/testproj/celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import absolute_import, unicode_literals

import os
import sys

from celery import Celery

from django.conf import settings

# Add the apps directory to the python path for celery to find the apps
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../..'))

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.testproj.settings')

app = Celery('tests.testproj')

app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
24 changes: 16 additions & 8 deletions settings.py → tests/testproj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
SECRET_KEY = 'testkey'

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'django.contrib.gis',

'raster',
)


MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
]

DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
Expand All @@ -32,12 +35,17 @@
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
],
},
},
]

ROOT_URLCONF = 'raster.urls'

RASTER_TILESIZE = 256
RASTER_USE_CELERY = True
CELERY_ALWAYS_EAGER = True
CELERY_EAGER_PROPAGATES = True

CELERY_TASK_ALWAYS_EAGER = True
CELERY_TASK_EAGER_PROPAGATES = True

0 comments on commit e4c0dc4

Please sign in to comment.