Exemplo n.º 1
0
def test_unicode_passed(scope, fixture_file):
    """
    Tests the `unicode` filename in `python2`.
    """
    include(six.text_type(fixture_file), scope=scope)  # unicode on py2, str on py3

    assert "FIXTURE_VALUE" in scope
Exemplo n.º 2
0
def test_empty_included_file(scope, fixture_file):
    """
    This test simulates normal behaviour when no `__included_file__`
    is provided in the `scope`.
    """
    include(fixture_file, scope=scope)

    assert "FIXTURE_VALUE" in scope
    assert "__included_file__" not in scope
Exemplo n.º 3
0
def test_caller_scope_automatically(fixture_file):
    """
    Tests `include` function for automatic `globals()`
    extraction from execution stack.
    Now you can omit positional argument `scope`.
    """
    include(fixture_file)

    assert "FIXTURE_VALUE" in globals()
Exemplo n.º 4
0
def test_keys_count(scope, fixture_file):
    """
    Scope must contain all base python attrs and a custom value.
    """
    include(fixture_file, scope=scope)

    # Keys:
    # 'FIXTURE_VALUE', '__file__', '__doc__',
    # '__builtins__', '__included_files__'
    assert len(scope.keys()) == 5
Exemplo n.º 5
0
def test_included_file_scope(scope, fixture_file):
    """
    This test emulates gunicorn behavior with `__included_file__` value.
    """
    base = os.path.dirname(__file__)

    saved_file = os.path.join(base, 'basic')

    scope['__included_file__'] = saved_file

    include(fixture_file, scope=scope)

    assert 'FIXTURE_VALUE' in scope
    assert scope['__included_file__'] == saved_file
Exemplo n.º 6
0
def test_included_file_scope(scope, fixture_file):
    """
    This test emulates gunicorn behaviour with `__included_file__` value.
    """
    base = os.path.dirname(__file__)

    saved_file = os.path.join(base, "settings")

    scope["__included_file__"] = saved_file

    include(fixture_file, scope=scope)

    assert "FIXTURE_VALUE" in scope
    assert scope["__included_file__"] == saved_file
Exemplo n.º 7
0
def test_unicode_filename(scope):
    """
    This represents the `hidden-unicode` situation.
    """

    file_path = os.path.join(
        'settings',  # this should be written as string
        'fixture_to_include.py'
    )

    include(
        file_path,
        scope=scope,
    )

    assert 'FIXTURE_VALUE' in scope
Exemplo n.º 8
0
def test_missing_file_error(scope):
    """
    This test covers the IOError, when file does not exist.
    """
    with pytest.raises(IOError):
        include("does-not-exist.py", scope=scope)
Exemplo n.º 9
0
# -*- coding: utf-8 -*-

import os

from split_settings.tools import optional, include

include(
    'base.py',
    'rest_framework.py',
    'lambdock_api.py',
    optional('local_settings.py'),
    scope=locals()
)

Exemplo n.º 10
0
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os

from split_settings.tools import include
from decouple import config

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

if os.environ['DJANGO_SETTINGS_MODULE'] == 'associados.settings.production':
    # must bypass this block if another settings module was specified
    include("base.py", scope=locals())

# SSL Setup

SECURE_SSL_REDIRECT = config('FORCE_HTTPS', cast=bool, default=False)
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# AWS Settings

STATIC_S3_PATH = "static"
DEFAULT_S3_PATH = "media"

AWS_ACCESS_KEY_ID = config('BUCKET_ACCESS_KEY', default='')
AWS_SECRET_ACCESS_KEY = config('BUCKET_SECRET_KEY', default='')
AWS_STORAGE_BUCKET_NAME = config('BUCKET_NAME', default='')
AWS_REGION_BUCKET_NAME = config("BUCKET_REGION", default='')
Exemplo n.º 11
0
# -*- coding: utf-8 -*-

import os

from split_settings.tools import optional, include

include(
    'admin.py',
    'lambdock_api.py',
    scope=locals()
)
Exemplo n.º 12
0
from split_settings.tools import optional, include
import os
import socket

if os.environ['DJANGO_SETTINGS_MODULE'] == 'example.settings':
    # must bypass this block if another settings module was specified
    include(
        "components/base.py",
        "components/locale.py",
        "components/apps_middleware.py",
        "components/static.py",
        "components/templates.py",
        "components/database.py",
        "components/logging.py",

        # OVERRIDE SETTINGS

        # hostname-based override, in settings/env/ directory
        optional("env/%s.py" % socket.gethostname().split(".", 1)[0]),

        # local settings (do not commit to version control)
        optional(os.path.join(os.getcwd(), "local_settings.py")),

        scope=locals()
    )
import os

import environ
from split_settings.tools import include

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

env = environ.Env(DEBUG=(bool, False), )  # set default values and casting
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))  # reading .env file

include('config/base.py', 'config/apps.py', 'config/db.py')

try:
    from .local_settings import *  # noqa
except ImportError:
    pass
from split_settings.tools import optional, include

include(
    # Load environment settings
    'base/env.py',
    optional('local/env.py'),  # We can "patch" any settings from local folder env.py file.

    # Here we should have the order because of dependencies
    'base/paths.py',
    'base/apps.py',
    'base/middleware.py',
    'base/debug_toolbar.py',

    # Load all other settings
    'base/*.py',

    optional('local/*.py'),  # we can load any other settings from local folder
)
Exemplo n.º 15
0
    if settings_path:
        site_settings = os.path.abspath(settings_path)

except KeyError:
    pass




include(
    'components/10-base.py',
    'components/11-apps.py',
    'components/12-identity.py',
    'components/13-credentials.py',
    'components/14-binaries.py',
    'components/20-media.py',
    'components/21-messaging.py',
    'components/30-template_cms.py',
    'components/99-depreciated.py',

    # via local_settings.py
    optional(site_settings),

    # via server based settings in etc (placed by ansible deployment tasks)
    optional('/etc/openbroadcast.org/application-settings.py'),
    optional('/etc/openbroadcast.org/application-secrets.py'),
    optional('/etc/openbroadcast.org/application-logging.py'),

    scope=locals()
)
Exemplo n.º 16
0
from os import path
from split_settings.tools import include

if path.isfile('/home/vagrant/rcbfp-backend-web/envars/local-mark'):
    print('connecting to local-mark settings...')
    include('settings_collection/local-mark.py')
elif path.isfile('/home/vagrant/rcbfp-backend-web/envars/test-server'):
    print('connecting to local-mark settings...')
    include('settings_collection/test-server.py')
elif path.isfile('/home/vagrant/rcbfp-backend-web/envars/test-server'):
    print('connecting to test-server settings...')
    include('settings_collection/test-server.py')
else:
    print('connecting to production settings...')
    include('settings_collection/productino.py')
Exemplo n.º 17
0
from __future__ import absolute_import

import os

from split_settings.tools import optional, include

ENV = os.environ.get('DJANGO_ENV', 'dev')

include(
    'base.py',
    '%s/channels.py' % ENV,
    '%s/database.py' % ENV,
    '%s/celery.py' % ENV,
    'email.py',
    'rest_framework.py'
)
Exemplo n.º 18
0
from split_settings.tools import include, optional

include(
    # load environment settings
    'base/env.py',
    optional('local/env.py'),

    # order matters because of dependencies
    'base/paths.py',
    'base/apps.py',
    'base/middleware.py',
    # 'base/debug_toolbar.py',

    # Load all other settings
    'base/*.py',

    optional('local/*.py'),  # load any other settings from local folder
)
Exemplo n.º 19
0
from os import environ

from split_settings.tools import include, optional

# Managing environment via DJANGO_ENV variable:
environ.setdefault('DJANGO_ENV', 'development')
ENV = environ['DJANGO_ENV']

base_settings = [
    'components/common.py',
    'components/databases.py',
    'components/caches.py',
    'components/logging.py',
    'components/celery.py',
    'components/rest_framework.py',
    'components/providers.py',
    'components/preferences.py',

    # You can even use glob:
    # 'components/*.py'

    # Select the right env:
    '{0}.py'.format(ENV),

    # Optionally override some settings:
    optional('local.py'),
]

# Include settings:
include(*base_settings)
Exemplo n.º 20
0
# -*- coding: utf-8 -*-

import os

import django

from split_settings.tools import optional, include

# Must bypass this block if another settings module was specified.
if os.environ['DJANGO_SETTINGS_MODULE'] == 'tests.settings':

    include('*.py')
Exemplo n.º 21
0
# -*- coding: utf-8 -*-
from split_settings.tools import include, optional

include(
    'components/base.py',
    'components/apps.py',
    'components/suit.py',
    'components/const.py',
    'components/static.py',
    optional('components/debug.py'),
)

# DEBUG = env('DJANGO_DEBUG', default=True)
DEBUG = True

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': str(ROOT_DIR.path('db.sqlite3')),
    }
}
Exemplo n.º 22
0
from split_settings.tools import include

include(
    'splitted_settings/installed_apps.py',
    'splitted_settings/middlewares.py',
    'splitted_settings/environ.py',
    'splitted_settings/boilerplate.py',
    'splitted_settings/db.py',
    'splitted_settings/bot.py',
    'splitted_settings/logging.py',
)

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',
            ],
        },
    },
]

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
Exemplo n.º 23
0
from split_settings.tools import include, optional
from os import environ

ENVIRONMENT = environ.get("DJANGO_ENV", "development")
assert ENVIRONMENT in (
    "development",
    "production",
), f"Unsupported environment {ENVIRONMENT}"

base_patterns = [
    "base.py",
    "auth.py",
    "templates.py",
    "api.py",
    "database.py",
    "logging.py",
    "extra.py",
    f'{ENVIRONMENT}.py',
]

include (*base_patterns)
Exemplo n.º 24
0
# -*- coding: utf-8 -*-

import os

import django

from split_settings.tools import optional, include

# Must bypass this block if another settings module was specified.
if os.environ["DJANGO_SETTINGS_MODULE"] == "tests.settings":

    include("*.py")
Exemplo n.º 25
0
from split_settings.tools import include


include(
    '__init__.py',
    'deploy.py',
    scope=globals()
)

ENV = 'stage'

ALLOWED_HOSTS = (
    '.stage.bnzk.ch',
)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3'.
        'NAME': "{{project_name}}_stage",  # Or path to db file if sqlite3.
        # mysl only
        # 'USER': '******',
        # 'PASSWORD': '******',
        # 'CONN_MAX_AGE': 0,  # set 0 if using gevent and no connection pooling!
        # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        # 'HOST': '',
        # Set to empty string for default.
        # 'PORT': '',
    }
}
Exemplo n.º 26
0
from split_settings.tools import include

STACKED_BASE_LOADED = True

include(
    'db/*.py'
)
Exemplo n.º 27
0
from split_settings.tools import optional, include

include(
    # Load environment settings
    'base/env.py',
    optional('local/env.py'
             ),  # We can "patch" any settings from local folder env.py file.

    # Here we should have the order because of dependencies
    'base/paths.py',
    'base/apps.py',
    'base/middleware.py',
    'base/debug_toolbar.py',

    # Load all other settings
    'base/*.py',
    optional('local/*.py'),  # we can load any other settings from local folder
)
Exemplo n.º 28
0
 include(
     "components/base.py",
     "components/debug.py",
     "components/db.py",
     "components/cache.py",
     "components/middleware.py",
     "components/static.py",
     "components/media.py",
     "components/templates.py",
     "components/email.py",
     "components/messages.py",
     "components/logging.py",
     "components/sessions.py",
     "components/security.py",
     "components/fixtures.py",
     "components/auth.py",
     "components/apps.py",
     "components/django-debug-toolbar.py",
     "components/django-storages.py",
     "components/python-social-auth.py",
     "components/cloudinary.py",
     "components/django-crispy-forms.py",
     "components/django-floppyforms.py",
     "components/django-suit.py",
     "components/disqus.py",
     "components/djrill.py",
     "components/djangorestframework.py",
     # 'components/django-oauth2-provider.py',
     # OVERRIDE SETTINGS
     # hostname-based override, in settings/env/ directory
     optional("env/%s.py" % socket.gethostname().split(".", 1)[0]),
     # local settings (do not commit to version control)
     optional(os.path.join(os.getcwd(), "local_settings.py")),
     scope=locals(),
 )
Exemplo n.º 29
0
# -*- coding: utf-8 -*-

from split_settings.tools import optional, include

include(
    'base.py',
    'south.py',
    'locale.py',
    'nose.py',
    'logger.py',
    'django_suit.py',
    'raven.py',
    'rosetta.py',
    'django_compressor.py',
    'test_presentation.py',
    optional('local_settings.py'),
    'debugtoolbar.py',
    scope=locals()
)
Exemplo n.º 30
0
from split_settings.tools import include

include(
    'common.py',
    'local.py',

    scope=locals()
)
Exemplo n.º 31
0
from split_settings.tools import optional, include

include("settings/base.py", "settings/database.py", optional("settings/local.py"), scope=globals())
Exemplo n.º 32
0
# -*- coding: utf-8 -*-

from split_settings.tools import include

urlpatterns = []

include(
    'test_presentation.py',
    'admin.py',
    'locale.py',
    'static.py',
    'rosetta.py',
    'debugtoolbar.py',
    scope=locals(),
)
Exemplo n.º 33
0
import django

from split_settings.tools import optional, include

# Must bypass this block if another settings module was specified.
if os.environ['DJANGO_SETTINGS_MODULE'] == 'tests.settings':

    include(
        'components/base.py',
        'components/locale.py',
        'components/apps_middleware.py',
        'components/static.py',
        'components/templates.py',
        'components/database.py',
        'components/logging.py',

        # Override settings for testing:
        optional('components/testing.py'),

        # Missing file:
        optional('components/missing_file.py'),

        # hostname-based override, in settings/env/ directory
        # optional('env/%s.py' % socket.gethostname().split('.', 1)[0]),

        # local settings (do not commit to version control)
        # optional(os.path.join(os.getcwd(), 'local_settings.py')),

        scope=globals()
    )
Exemplo n.º 34
0
# -*- coding: utf-8 -*-

from split_settings.tools import optional, include
from components import CONFIG

# To change settings file:
# `python manage.py runserver --settings=django_orm_example.other_settings`

if CONFIG['DJANGO_SETTINGS_MODULE'] == 'django_orm_example.settings':
    testing = bool(CONFIG['_DJANGO_TESTING'])

    base_settings = [
        'components/common.py',
        # 'components/constants.py',
        'components/queues.py',
    ]

    if not testing:
        settings = base_settings + [
            'environments/production.py',
            optional('environments/development.py'),
        ]

    else:
        settings = base_settings + [
            'environments/testing.py',
        ]

    # Include settings for the current env:
    include(*settings, scope=globals())
Exemplo n.º 35
0
import os

from split_settings.tools import optional, include
from unipath import Path

PROJECT_PATH = Path()


def rel(*x):
    return PROJECT_PATH.child(*x).absolute()

os.sys.path.insert(1, str(rel('apps')))

include(
    'components/base.py',
    'components/auth.py',
    'components/locale.py',
    'components/static.py',
    'components/templates.py',
    'components/db_and_cache.py',
    'components/middleware.py',
    'components/apps.py',
    'components/logging.py',
    'components/libs.py',
    optional('local.py'),
    scope=locals()
)
Exemplo n.º 36
0
from split_settings.tools import optional, include

include(
    'base.py',
    'assets.py',
    'apps.py',
    'cms.py',
    'placeholders.py',
    'ckeditor.py',
    '_{{ project_name }}_dev.py',
    optional('local.py'),
    scope=globals()
)
Exemplo n.º 37
0
from split_settings.tools import optional, include

# Settings are split using split_settings:
# https://github.com/sobolevn/django-split-settings
#
# * Universal settings for openbare live in settings.base.
# * All local settings are imported as well, and supercede base settings.
#   Keep your dev settings here. A template is provided for getting you started:
#   settings/local_development.py.template
# * System-wide settings not appropriate for settings.base belong in
#   /etc/openbare/settings_*.py
# * Templates are provided for public setting files for:
#   DB, Session Secret, AWS, Logging.

include(
    "base.py", # was settings.py
    optional("local_*.py"), # def settings - ignored by git
    optional("/etc/openbare/settings_*.py"), # production settings
    scope=locals()
)
Exemplo n.º 38
0
# -*- coding: utf-8 -*-
"""
Settings for staging platforms which serves project builds.
"""
# Import global settings to make it easier to extend settings.
from django.conf.global_settings import * # pylint: disable=W0614,W0401

from split_settings.tools import include, optional


include(
    'components/shared/paths.py',
    'components/staging/paths.py',

    'components/shared/base.py',
    'components/staging/base.py',

    optional('components/staging/private.py'),

    'components/shared/sessions.py',
    'components/shared/admin.py',

    scope=locals()
)
Exemplo n.º 39
0
from split_settings.tools import optional, include
from os import environ

ENV = environ.get('DJANGO_ENV') or 'development'

base_settings = [
    'common.py',  # standard django settings
    'database.py',  # postgres
    # 'emails.py',

    # Select the right env:
    '%s.py' % ENV,
    # Optionally override some settings:
    optional('local.py'),
]

# Include settings:
include(*base_settings)
# -*- coding: utf-8 -*-
"""
Settings for production platforms which serves real projects.
"""
# Import global settings to make it easier to extend settings.
from django.conf.global_settings import * # pylint: disable=W0614,W0401

from split_settings.tools import include, optional


include(
    'components/shared/paths.py',
    optional('components/production/paths.py'),

    'components/shared/base.py',
    optional('components/production/base.py'),

    'components/shared/sessions.py',
    'components/shared/admin.py',

    scope=locals()
)
from split_settings.tools import optional, include

include(
    'components/base.py',
    'components/apps_middleware.py',
    'components/database.py',
    'components/templates.py',
    'components/static.py',
    'components/media.py',
    'components/logging.py',
    'components/locale.py',
    optional('local_settings.py'),
    scope=globals()
)
Exemplo n.º 42
0
from split_settings.tools import optional, include
import os

try:
    site_domain = os.environ['SITE']
except:
    site_domain = None


if not site_domain:

    include(
        'components/base.py',
        'components/media.py',
        'components/template_cms.py',

        os.path.join(os.getcwd(), 'project/local_settings.py'),
        scope=locals()
    )



Exemplo n.º 43
0
# Configure a default UUID for development only.
SYSTEM_UUID = '00000000-0000-0000-0000-000000000000'
INSTALL_UUID = '00000000-0000-0000-0000-000000000000'

# Store a snapshot of default settings at this point before loading any
# customizable config files.
DEFAULTS_SNAPSHOT = {}
this_module = sys.modules[__name__]
for setting in dir(this_module):
    if setting == setting.upper():
        DEFAULTS_SNAPSHOT[setting] = copy.deepcopy(
            getattr(this_module, setting))

# If there is an `/etc/tower/settings.py`, include it.
# If there is a `/etc/tower/conf.d/*.py`, include them.
include(optional('/etc/tower/settings.py'), scope=locals())
include(optional('/etc/tower/conf.d/*.py'), scope=locals())

BASE_VENV_PATH = "/venv/"
ANSIBLE_VENV_PATH = os.path.join(BASE_VENV_PATH, "ansible")
AWX_VENV_PATH = os.path.join(BASE_VENV_PATH, "awx")

# If any local_*.py files are present in awx/settings/, use them to override
# default settings for development.  If not present, we can still run using
# only the defaults.
try:
    include(optional('local_*.py'), scope=locals())
except ImportError:
    traceback.print_exc()
    sys.exit(1)