113 lines
2.7 KiB
Python
113 lines
2.7 KiB
Python
|
#!/usr/bin/env python
|
||
|
import os
|
||
|
import sys
|
||
|
|
||
|
import django
|
||
|
|
||
|
from django.conf import settings
|
||
|
|
||
|
|
||
|
DEFAULT_SETTINGS = dict(
|
||
|
|
||
|
DEBUG = False,
|
||
|
|
||
|
DATABASES = {
|
||
|
'default': {
|
||
|
'ENGINE': 'django.db.backends.sqlite3',
|
||
|
'NAME': ':memory:',
|
||
|
}
|
||
|
},
|
||
|
|
||
|
SITE_ID = 1,
|
||
|
|
||
|
MIDDLEWARE_CLASSES = [
|
||
|
'django.middleware.common.CommonMiddleware',
|
||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||
|
],
|
||
|
|
||
|
TEMPLATES = [
|
||
|
{
|
||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||
|
'DIRS': [],
|
||
|
'APP_DIRS': True,
|
||
|
'OPTIONS': {
|
||
|
'context_processors': [
|
||
|
'django.template.context_processors.debug',
|
||
|
'django.template.context_processors.request',
|
||
|
'django.contrib.auth.context_processors.auth',
|
||
|
'django.contrib.messages.context_processors.messages',
|
||
|
],
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
|
||
|
LOGGING = {
|
||
|
'version': 1,
|
||
|
'disable_existing_loggers': False,
|
||
|
'handlers': {
|
||
|
'console': {
|
||
|
'class': 'logging.StreamHandler',
|
||
|
},
|
||
|
},
|
||
|
'loggers': {
|
||
|
'oidc_provider': {
|
||
|
'handlers': ['console'],
|
||
|
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
|
||
|
INSTALLED_APPS = [
|
||
|
'django.contrib.auth',
|
||
|
'django.contrib.contenttypes',
|
||
|
'django.contrib.sessions',
|
||
|
'django.contrib.sites',
|
||
|
'django.contrib.messages',
|
||
|
'django.contrib.admin',
|
||
|
'oidc_provider',
|
||
|
],
|
||
|
|
||
|
SECRET_KEY = 'this-should-be-top-secret',
|
||
|
|
||
|
ROOT_URLCONF = 'oidc_provider.tests.app.urls',
|
||
|
|
||
|
TEMPLATE_DIRS = [
|
||
|
'oidc_provider/tests/templates',
|
||
|
],
|
||
|
|
||
|
USE_TZ = True,
|
||
|
|
||
|
# OIDC Provider settings.
|
||
|
|
||
|
SITE_URL = 'http://localhost:8000',
|
||
|
OIDC_USERINFO = 'oidc_provider.tests.app.utils.userinfo',
|
||
|
|
||
|
)
|
||
|
|
||
|
|
||
|
def runtests(*test_args):
|
||
|
if not settings.configured:
|
||
|
settings.configure(**DEFAULT_SETTINGS)
|
||
|
|
||
|
django.setup()
|
||
|
|
||
|
parent = os.path.dirname(os.path.abspath(__file__))
|
||
|
sys.path.insert(0, parent)
|
||
|
|
||
|
try:
|
||
|
from django.test.runner import DiscoverRunner
|
||
|
runner_class = DiscoverRunner
|
||
|
test_args = ["oidc_provider.tests"]
|
||
|
except ImportError:
|
||
|
from django.test.simple import DjangoTestSuiteRunner
|
||
|
runner_class = DjangoTestSuiteRunner
|
||
|
test_args = ["tests"]
|
||
|
|
||
|
failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
|
||
|
sys.exit(failures)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
runtests(*sys.argv[1:])
|