Monday, February 1, 2016

Re: How should it make django test create a default_test database that is using 5 shemas ?


here is my settings :

"""
Django settings for james project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

DATA_DIR = '/var/lib/james'
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '33333333333333333333333333'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []

import os
import sys
import ConfigParser

c = ConfigParser.ConfigParser()
c.optionxform = str
CONFIG_PATH = '/etc/james/james.cfg'
if not os.path.exists(CONFIG_PATH):
    print 'Config file not found in:', CONFIG_PATH
    CONFIG_PATH = os.path.expanduser('~/.james3.cfg')
    if not os.path.exists(CONFIG_PATH):
        raise Exception('Missing james.cfg file! Not found in /etc/james/james.cfg or ~/.james.cfg.')

print 'Using config:', CONFIG_PATH
c.read(CONFIG_PATH)


BASE_DIR = os.path.dirname(os.path.dirname(__file__))

# Application definition

INSTALLED_APPS = [
    'grappelli',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sites',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # 'registration',
    'genesis',
    'reversion',
    'django_jinja',
    'status',
    'configuration',
    'administration',
    'old_link',
    'chartjs',
    ]

MIDDLEWARE_CLASSES = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'james.util.requestprovider.RequestProvider',
    # TODO: test performance of this middleware
    'reversion.middleware.RevisionMiddleware',
    'james.middleware.CurrentContext'
]

ROOT_URLCONF = 'james.urls'

WSGI_APPLICATION = 'james.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
    'default': {
        'ENGINE': c.get('default-database', 'ENGINE'),
        'NAME': c.get('default-database', 'NAME'),
        'USER': c.get('default-database', 'USER'),
        'PASSWORD': c.get('default-database', 'PASSWORD'),
        'HOST': c.get('default-database', 'HOST'),
        'PORT': c.get('default-database', 'PORT'),
        'OPTIONS': {
            'options': '-c search_path=store,site,portal'
        },
        }
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
# TIME_ZONE = 'UTC'
TIME_ZONE = 'America/New_York'
USE_I18N = True
USE_L10N = True
USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static_gen")
STATICFILES_DIRS = (
    '/srv/www/james/static/',
    os.path.join(BASE_DIR, "static"),
)

LOGIN_REDIRECT_URL = "/"

TEMPLATES = [
    {
        "BACKEND": "django_jinja.backend.Jinja2",
        "APP_DIRS": True,
        "OPTIONS": {
            "match_extension": ".j2",
            "newstyle_gettext": True,
            "filters": {
                "timestamp2date": "james.filters.timestamp2date",
                "format_datetime": "james.filters.format_datetime",
                },

            "context_processors": [
                "django.contrib.auth.context_processors.auth",
                "django.template.context_processors.debug",
                "django.template.context_processors.i18n",
                "django.template.context_processors.media",
                "django.template.context_processors.static",
                "django.template.context_processors.tz",
                "django.contrib.messages.context_processors.messages",
                'james.context_processors.customers',
                ],

            "extensions": [
                "jinja2.ext.do",
                "jinja2.ext.loopcontrols",
                "jinja2.ext.with_",
                "jinja2.ext.i18n",
                "jinja2.ext.autoescape",
                "django_jinja.builtins.extensions.CsrfExtension",
                "django_jinja.builtins.extensions.CacheExtension",
                "django_jinja.builtins.extensions.TimezoneExtension",
                "django_jinja.builtins.extensions.UrlsExtension",
                "django_jinja.builtins.extensions.StaticFilesExtension",
                "django_jinja.builtins.extensions.DjangoFiltersExtension",
                ],
            "autoescape": True,
            "auto_reload": DEBUG,
            "translation_engine": "django.utils.translation",
            },
        'DIRS': [
            '/srv/www/james/templates/',
            os.path.join(BASE_DIR, "templates"),
            ],
        },
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,

        "OPTIONS": {

            "context_processors": [
                "django.contrib.auth.context_processors.auth",
                "django.template.context_processors.debug",
                "django.template.context_processors.i18n",
                "django.template.context_processors.media",
                "django.template.context_processors.static",
                "django.template.context_processors.tz",
                "django.contrib.messages.context_processors.messages",
                ],
            },
        },
    ]


EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = c.get('mail', 'smtp_host')
EMAIL_PORT = 25
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False

SUPPORT_EMAIL = ""
DEFAULT_FROM_EMAIL = ""


LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format': "[%(asctime)s] %(levelname)s [%(module)s.%(funcName)s:%(lineno)s] %(process)d %(thread)d %(message)s",
            'datefmt': "%d/%b/%Y %H:%M:%S"
        },
        'exception': {
            'format': "[%(asctime)s] %(levelname)s [%(filename)s:%(funcName)s:%(lineno)s] %(process)d %(thread)d %(message)s",
            'datefmt': "%d/%b/%Y %H:%M:%S"
        },
        },
    'handlers': {
        'stderr': {
            'level': c.get('logging', 'log_level'),
            'class': 'logging.StreamHandler',
            'formatter': 'standard'
        },
        # 'file': {
        #     'level': 'DEBUG',
        #     'class': 'logging.FileHandler',
        #     'filename': '/path/to/django/debug.log',
        # },
    },
    'loggers': {
        'django': {
            'handlers': ['stderr'],
            'propagate': True,
            'level': 'WARNING',
            },
        'james': {
            'handlers': ['stderr'],
            'propagate': True,
            'level': 'DEBUG',
            },
        },
    }

## Later..
# CACHES = {
#     'default': {
#         'BACKEND': 'redis_cache.RedisCache',
#         'LOCATION': ['localhost:6379'],
#         'OPTIONS': {
#             'PARSER_CLASS': 'redis.connection.HiredisParser',
#             'CONNECTION_POOL_CLASS': 'redis.BlockingConnectionPool',
#             'CONNECTION_POOL_CLASS_KWARGS': {
#                 'max_connections': 50,
#                 'timeout': 20,
#             },
#             'MAX_CONNECTIONS': 1000,
#             'PICKLE_VERSION': -1,
#         },
#     },
# }

SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'

GRAPPELLI_ADMIN_TITLE = 'james / [advanced admin interface]'
GRAPPELLI_CLEAN_INPUT_TYPES = True

# APIs
API_URL_SITES = c.get('api', 'API_URL_SITES')
API_URL_CAPTIVE_PORTAL = c.get('api', 'API_URL_CAPTIVE_PORTAL')
ALLOWED_UPLOAD_EXTENSIONS = ("zip",)
UPLOAD_FOLDER = "/tmp/"

AUTHENTICATION_BACKENDS = (
    'james.auth.EmailAuthBackend',
    'administration.auth.LdapAuthBackend',
)



if 'test' in sys.argv:
        DATABASES['default'] = {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': c.get('default-database', 'NAME'),
            'HOST' : c.get('default-database', 'HOST'),
            'TEST_NAME':'',
            'PORT' : c.get('default-database', 'PORT'),
            'USER' : c.get('default-database', 'USER'),
            'PASSWORD':c.get('default-database', 'PASSWORD'),
            'options': '-c search_path=james,site,portal,public,dvdns'

        }



DATABASE_ROUTERS = []
MIGRATION_MODULES = {
        'ldapauth':'ldapauth.migrations_not_used_in_tests',
        'provisioning':'provisioning.migrations_not_used_in_tests',
        'services':'services.migrations_not_used_in_tests'
    }



SITE_ID = 1
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
REGISTRATION_AUTO_LOGIN = True # Automatically log the user in.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b4bc6ce8-79ab-44dc-a960-901aad559c9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment