def test_database_url_value(self):
     value = DatabaseURLValue()
     self.assertEqual(value.default, {})
     with env(DATABASE_URL='sqlite://'):
         self.assertEqual(value.setup('DATABASE_URL'), {
             'default': {
                 'ENGINE': 'django.db.backends.sqlite3',
                 'HOST': '',
                 'NAME': ':memory:',
                 'PASSWORD': '',
                 'PORT': '',
                 'USER': '',
             }})
Ejemplo n.º 2
0
 def test_database_url_value(self):
     value = DatabaseURLValue()
     self.assertEqual(value.default, {})
     with env(DATABASE_URL='sqlite://'):
         self.assertEqual(value.setup('DATABASE_URL'), {
             'default': {
                 'ENGINE': 'django.db.backends.sqlite3',
                 'HOST': '',
                 'NAME': ':memory:',
                 'PASSWORD': '',
                 'PORT': '',
                 'USER': '',
             }})
Ejemplo n.º 3
0
    def test_database_url_additional_args(self):

        def mock_database_url_caster(self, url, engine=None):
            return { 'URL': url, 'ENGINE': engine }

        with patch('configurations.values.DatabaseURLValue.caster', mock_database_url_caster):
            value = DatabaseURLValue(engine='django_mysqlpool.backends.mysqlpool')
            with env(DATABASE_URL='sqlite://'):
                self.assertEqual(value.setup('DATABASE_URL'), {
                    'default': {
                        'URL': 'sqlite://',
                        'ENGINE': 'django_mysqlpool.backends.mysqlpool'
                    }
                })
Ejemplo n.º 4
0
    def test_database_url_additional_args(self):
        def mock_database_url_caster(self, url, engine=None):
            return {'URL': url, 'ENGINE': engine}

        with patch('configurations.values.DatabaseURLValue.caster',
                   mock_database_url_caster):
            value = DatabaseURLValue(
                engine='django_mysqlpool.backends.mysqlpool')
            with env(DATABASE_URL='sqlite://'):
                self.assertEqual(
                    value.setup('DATABASE_URL'), {
                        'default': {
                            'URL': 'sqlite://',
                            'ENGINE': 'django_mysqlpool.backends.mysqlpool'
                        }
                    })
Ejemplo n.º 5
0
 def test_database_url_value(self):
     value = DatabaseURLValue()
     self.assertEqual(value.default, {})
     with env(DATABASE_URL="sqlite://"):
         self.assertEqual(
             value.setup("DATABASE_URL"),
             {
                 "default": {
                     "ENGINE": "django.db.backends.sqlite3",
                     "HOST": "",
                     "NAME": ":memory:",
                     "PASSWORD": "",
                     "PORT": "",
                     "USER": "",
                 }
             },
         )
class DeploymentConfig(object):
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = 'replacethiswithsomethingsecret'

    # SECURITY WARNING: don't run with debug turned on in production!
    # Set this to True while you are developing
    DEBUG = BooleanValue(True)

    POLIS_SITE_ID = Value(None)

    # Unrestricted staging key (disposable)
    GMAPS_API_KEY = Value('AIzaSyDVJdClcbq1ioJUeySpPgNiDndQEspN6Ck')
    # Set this to a "frozen version" in production
    # See: https://developers.google.com/maps/documentation/javascript/versions#the-frozen-version
    GMAPS_API_VERSION = Value('3.exp')

    # See: https://django-configurations.readthedocs.org/en/stable/values/#configurations.values.DatabaseURLValue
    DATABASES = DatabaseURLValue('sqlite:///tor_councilmatic.db')

    # See: https://django-configurations.readthedocs.org/en/stable/values/#configurations.values.SearchURLValue
    # See: https://github.com/dstufft/dj-search-url
    HAYSTACK_CONNECTIONS = SearchURLValue('simple://')

    # See: https://django-configurations.readthedocs.org/en/stable/values/#configurations.values.CacheURLValue
    # See: https://github.com/ghickman/django-cache-url
    CACHES = CacheURLValue('dummy://')

    # Set this to flush the cache at /flush-cache/{FLUSH_KEY}
    FLUSH_KEY = 'super secret junk'

    # Set this to allow Disqus comments to render
    DISQUS_SHORTNAME = None

    # analytics tracking code
    ANALYTICS_TRACKING_CODE = Value('')

    HEADSHOT_PATH = os.path.join(os.path.dirname(__file__), '..'
                                 '/toronto/static/images/')

    EXTRA_APPS = ()
Ejemplo n.º 7
0
class Base(Configuration):

    PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
    BASE_DIR = os.path.dirname(PROJECT_ROOT)
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')

    DEBUG = False
    ALLOWED_HOSTS = []

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django_extensions',
        'core',
        'users',
        'courses',
    ]

    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ]

    ROOT_URLCONF = 'core.urls'

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
            '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',
                ],
            },
        },
    ]

    WSGI_APPLICATION = 'core.wsgi.application'

    DATABASES = DatabaseURLValue('sqlite:///db.sqlite3')

    AUTH_USER_MODEL = 'users.User'
    #     {
    #     'default': {
    #         'ENGINE': 'django.db.backends.sqlite3',
    #         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    #     }
    # }

    AUTH_PASSWORD_VALIDATORS = [
        {
            'NAME':
            'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        },
        {
            'NAME':
            'django.contrib.auth.password_validation.MinimumLengthValidator',
        },
        {
            'NAME':
            'django.contrib.auth.password_validation.CommonPasswordValidator',
        },
        {
            'NAME':
            'django.contrib.auth.password_validation.NumericPasswordValidator',
        },
    ]

    LANGUAGE_CODE = 'en-us'

    TIME_ZONE = 'UTC'

    USE_I18N = True

    USE_L10N = True

    USE_TZ = True

    STATIC_URL = '/static/'

    LOGIN_REDIRECT_URL = '/'