예제 #1
0
    def test_coercion_function_receives_returned_value(self):
        value = 'foo-%s' % random.randint(1000, 2000)
        os.environ['random-value'] = value

        def type_func(a):
            self.assertEqual(a, value)

        get_env('random-value', 'default', type_func=type_func)
예제 #2
0
    def test_can_be_coerced_by_a_func(self):
        def type_func(value):
            self.assertEqual(value, 'Hi, Dad!')
            return 'Hi, Mom!'

        result = get_env('foo', 'Hi, Dad!', type_func=type_func)
        self.assertEqual('Hi, Mom!', result)
예제 #3
0
    def test_returns_different_default_based_on_environment(self):
        default = 'foobar'
        dev_default = 'barfoo'
        os.environ['ENVIRONMENT'] = 'dev'

        self.assertEqual(dev_default, get_env('not-set', default,
                dev=dev_default))
예제 #4
0
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = helpers.project_dir('static')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = get_env('STATIC_URL', '/static/')

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = get_env('ADMIN_MEDIA_PREFIX', '%sadmin/' % STATIC_URL)

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    helpers.project_dir('public'), )

# List of finder classes that know how to find static files in
# various locations.
예제 #5
0
    def test_can_force_to_boolean(self):
        self.assertTrue(get_env('foo', True, force_bool=True) is True)
        self.assertTrue(get_env('foo', '1', force_bool=True) is True)
        self.assertTrue(get_env('foo', 'yes', force_bool=True) is True)
        self.assertTrue(get_env('foo', 'true', force_bool=True) is True)
        self.assertTrue(get_env('foo', 'True', force_bool=True) is True)
        self.assertTrue(get_env('foo', 'TRUE', force_bool=True) is True)

        self.assertTrue(get_env('foo', False, force_bool=True) is False)
        self.assertTrue(get_env('foo', '0', force_bool=True) is False)
        self.assertTrue(get_env('foo', 'no', force_bool=True) is False)
        self.assertTrue(get_env('foo', 'false', force_bool=True) is False)
        self.assertTrue(get_env('foo', 'False', force_bool=True) is False)
        self.assertTrue(get_env('foo', 'FALSE', force_bool=True) is False)
예제 #6
0
 def test_returns_env_var_if_set(self):
     a = '%s' % random.randint(1000, 2000)
     os.environ['some-test-key-%s' % a] = a
     self.assertEqual(a, get_env('some-test-key-%s' % a, 'default'))
     del os.environ['some-test-key-%s' % a]
예제 #7
0
 def test_returns_default_if_no_env_var_set(self):
     default = 'foobar'
     self.assertEqual(default, get_env('unknown-and-unknowable', default))
예제 #8
0
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = helpers.project_dir('static')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = get_env('STATIC_URL', '/static/')

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = get_env('ADMIN_MEDIA_PREFIX', '%sadmin/' % STATIC_URL)

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    helpers.project_dir('public'),
)

# List of finder classes that know how to find static files in