Esempio n. 1
0
        'default': dj_database_url.config(
            default='postgres://*****:*****@localhost:5432/connectdb'
        )
    }

    # TESTING
    TEST_RUNNER = 'django_behave.runner.DjangoBehaveTestSuiteRunner'


class ProductionSettings(BaseSettings):
    @property
    def INSTALLED_APPS(self):
        return super().INSTALLED_APPS + ('djrill',)

    EMAIL_BACKEND = 'djrill.mail.backends.djrill.DjrillBackend'
    MANDRILL_API_KEY = os.getenv('MANDRILL_API_KEY')

    # DATABASE
    # set this config by setting an environment called DATABASE_URL,
    # eg: postgres://username:[email protected]:port/database-name
    DATABASES = {
        'default': dj_database_url.config(
            default='postgres://*****:*****@localhost:5432/connectdb'
        )
    }


# Now, let's activate our settings
MODE = os.getenv('DJANGO_MODE', 'Local')
cbs.apply('{}Settings'.format(MODE.title()), globals())
Esempio n. 2
0
    def test_apply_settings_string_local(self):
        g = {'AttrSettings': AttrSettings}
        cbs.apply('AttrSettings', g)

        self.assertEqual(g['PROJECT_NAME'], 'fancy_project')
Esempio n. 3
0
    def test_apply_settings_string_reference(self):
        g = {}
        cbs.apply(__name__ + '.AttrSettings', g)

        self.assertEqual(g['PROJECT_NAME'], 'fancy_project')
Esempio n. 4
0
    def test_apply_settings_attr(self):
        g = {}
        cbs.apply(AttrSettings, g)

        self.assertEqual(g['PROJECT_NAME'], 'fancy_project')
Esempio n. 5
0
    def test_apply_settings_method(self):
        g = {}
        cbs.apply(MethodSettings, g)

        self.assertEqual(g['PROJECT_NAME'], 'fancy_project')
    def test_apply_settings_method(self):
        cbs.apply(MethodSettings, globals())

        self.assertEqual(PROJECT_NAME, 'fancy_project')
    def test_apply_settings_string_reference(self):
        cbs.apply(__name__ + '.AttrSettings', globals())

        self.assertEqual(PROJECT_NAME, 'fancy_project')
    def test_apply_settings_attr(self):
        cbs.apply(AttrSettings, globals())

        self.assertEqual(PROJECT_NAME, 'fancy_project')
Esempio n. 9
0
    DEBUG = True

    DEFAULT_DB = 'postgres://*****:*****@localhost:5434/yanlog'

    INSTALLED_APPS = Base.INSTALLED_APPS + (
        'debug_toolbar',
        'django_extensions',
    )


class Test(Base):
    """ Settings for testing env """

    @cbs.env
    def DEFAULT_DB(self):
        # Uses postgres started by docker-compose by default
        return 'postgres://*****:*****@localhost:5434/yanlog'

    SECRET_KEY = 'ul06ndw!fop^owsfzx1x#zh)!%2scv!#!ox1e^9%rrz1&v^bf-'


class Prod(Base):
    """ Settings for production """

    DEBUG = False


MODE = os.environ.get('DJANGO_MODE', 'Local').title()
cbs.apply(MODE, globals())
import os

import cbs

mode = os.environ.get('DJANGO_MODE', 'Local')

cbs.apply('settings.{}.{}Settings'.format(mode.lower(), mode.title()), globals())
    def test_precedence_non_empty_global_setting(self):
        g = {}
        cbs.apply(MySettings, g)

        self.assertIn('default', g['CACHES'])
        self.assertIn('custom', g['CACHES'])
    def test_precedence_empty_global_setting(self):
        g = {}
        cbs.apply(MySettings, g)

        self.assertEqual(['test'], g['INSTALLED_APPS'])