Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ release: clean ## package and upload a release
dist: clean ## build python package ditribution
python setup.py sdist bdist_wheel
ls -l dist

syncdb: ## apply all migrations and load fixtures
python manage.py migrate
python manage.py migrate --run-syncdb
python manage.py loaddata one_to_one many_to_one many_to_many
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
alchemy-mock
coreapi
coverage
django-debug-toolbar
django-debug-toolbar-alchemy
django-extensions
djangorestframework
flake8
Expand Down
6 changes: 6 additions & 0 deletions test_project/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
Session = sessionmaker(bind=settings.SQLALCHEMY_ENGINE)


def dbs():
return {
'default': settings.SQLALCHEMY_ENGINE,
}


class SQLAlchemySessionMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
Expand Down
51 changes: 45 additions & 6 deletions test_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
# Bare ``settings.py`` for running tests for url_filter
import os

from sqlalchemy import create_engine


DEBUG = True
INTERNAL_IPS = ['127.0.0.1']

SQLALCHEMY_ENGINE = create_engine('sqlite:///url_filter.sqlite', echo=True)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'url_filter.sqlite'
if os.environ.get('USE_POSTGRES') == 'True':
SQLALCHEMY_ENGINE = create_engine('postgresql://postgres:test@localhost:5432', echo=True)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'test',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
else:
SQLALCHEMY_ENGINE = create_engine('sqlite:///url_filter.sqlite', echo=True)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'url_filter.sqlite'
}
}
}

INSTALLED_APPS = (
'test_project.generic',
Expand All @@ -20,6 +36,8 @@

'url_filter',

'debug_toolbar',
'debug_toolbar_alchemy',
'django_extensions',
'rest_framework',

Expand All @@ -33,6 +51,7 @@

MIDDLEWARE = [
'test_project.middleware.SQLAlchemySessionMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
]

TEMPLATES = [
Expand All @@ -49,3 +68,23 @@
'url_filter.integrations.drf.DjangoFilterBackend',
],
}

DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar_alchemy.panels.sql.SQLPanel',
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
]

DEBUG_TOOLBAR_CONFIG = {
'ALCHEMY_DB_ALIASES': 'test_project.middleware.dbs',
}
10 changes: 10 additions & 0 deletions test_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals

import debug_toolbar
from django.conf import settings
from django.conf.urls import url
from django.urls import include
from rest_framework.routers import DefaultRouter

from test_project.generic import api as g_api
Expand Down Expand Up @@ -33,3 +37,9 @@
router.register('generic/b', g_api.ModelBViewSet, 'generic|b')

urlpatterns = router.urls


if settings.DEBUG:
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]