2014-03-02 15:40:30 +04:00
|
|
|
def pytest_configure():
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
settings.configure(
|
|
|
|
DEBUG_PROPAGATE_EXCEPTIONS=True,
|
|
|
|
DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
'NAME': ':memory:'}},
|
|
|
|
SECRET_KEY='not very secret in tests',
|
|
|
|
USE_I18N=True,
|
|
|
|
USE_L10N=True,
|
|
|
|
STATIC_URL='/static/',
|
|
|
|
ROOT_URLCONF='tests.urls',
|
|
|
|
TEMPLATE_LOADERS=(
|
|
|
|
'django.template.loaders.filesystem.Loader',
|
|
|
|
'django.template.loaders.app_directories.Loader',
|
|
|
|
),
|
|
|
|
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',
|
|
|
|
),
|
|
|
|
INSTALLED_APPS=(
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.messages',
|
2014-05-01 10:36:18 +04:00
|
|
|
'django.contrib.staticfiles',
|
2014-03-02 15:40:30 +04:00
|
|
|
|
|
|
|
'rest_framework',
|
|
|
|
'rest_framework.authtoken',
|
|
|
|
'tests',
|
|
|
|
'tests.accounts',
|
|
|
|
'tests.records',
|
|
|
|
'tests.users',
|
|
|
|
),
|
|
|
|
PASSWORD_HASHERS=(
|
|
|
|
'django.contrib.auth.hashers.SHA1PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.MD5PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.CryptPasswordHasher',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
2014-08-19 16:54:52 +04:00
|
|
|
import oauth_provider # NOQA
|
|
|
|
import oauth2 # NOQA
|
2014-03-02 15:40:30 +04:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
settings.INSTALLED_APPS += (
|
|
|
|
'oauth_provider',
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
2014-08-19 16:54:52 +04:00
|
|
|
import provider # NOQA
|
2014-03-02 15:40:30 +04:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
settings.INSTALLED_APPS += (
|
|
|
|
'provider',
|
|
|
|
'provider.oauth2',
|
|
|
|
)
|
|
|
|
|
|
|
|
# guardian is optional
|
|
|
|
try:
|
2014-08-19 16:54:52 +04:00
|
|
|
import guardian # NOQA
|
2014-03-02 15:40:30 +04:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
settings.ANONYMOUS_USER_ID = -1
|
|
|
|
settings.AUTHENTICATION_BACKENDS = (
|
2014-08-19 16:54:52 +04:00
|
|
|
'django.contrib.auth.backends.ModelBackend',
|
2014-03-02 15:40:30 +04:00
|
|
|
'guardian.backends.ObjectPermissionBackend',
|
|
|
|
)
|
|
|
|
settings.INSTALLED_APPS += (
|
|
|
|
'guardian',
|
|
|
|
)
|
2014-04-17 16:30:33 +04:00
|
|
|
|
|
|
|
try:
|
|
|
|
import django
|
|
|
|
django.setup()
|
|
|
|
except AttributeError:
|
|
|
|
pass
|