Skip to content

Commit

Permalink
Added test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
s-m-i-t-a committed Aug 3, 2014
1 parent 0c7f77c commit 18de918
Show file tree
Hide file tree
Showing 7 changed files with 3,123 additions and 0 deletions.
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
from django.conf import settings


def pytest_configure():
if not settings.configured:
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
3,006 changes: 3,006 additions & 0 deletions runtests.py

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
DEBUG = False
TEMPLATE_DEBUG = DEBUG

TIME_ZONE = 'UTC'
LANGUAGE_CODE = 'en-US'
SITE_ID = 1
USE_L10N = True
USE_TZ = True

SECRET_KEY = 'local'

ROOT_URLCONF = 'tests.urls'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
# 'NAME': 'dev.db',
}
}

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.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
]

TEMPLATE_CONTEXT_PROCESSORS = [
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages'
]

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'south',

'sales_flatpages',

'tests',
)

PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher',
)

import django
if django.VERSION < (1, 4):
TEMPLATE_CONTEXT_PROCESSORS.remove('django.core.context_processors.tz')
MIDDLEWARE_CLASSES.remove(
'django.middleware.clickjacking.XFrameOptionsMiddleware'
)
1 change: 1 addition & 0 deletions tests/templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>404!!!!</h1>
Empty file added tests/templates/blank.html
Empty file.
12 changes: 12 additions & 0 deletions tests/templates/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head></head>
<body>
{% if messages %}
{% for message in messages %}
{{ message }}
{% endfor %}
{% endif %}

{{ form.as_p }}
</body>
</html>
26 changes: 26 additions & 0 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import unicode_literals

from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),

# Your stuff: custom urls go here

) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


urlpatterns += patterns(
'django.contrib.auth.views',
# login page, required by some tests
url(r'^accounts/login/$', 'login', {'template_name': 'blank.html'}),
url(r'^auth/login/$', 'login', {'template_name': 'blank.html'}),
)

0 comments on commit 18de918

Please sign in to comment.