Example #1
0
def test_envelop_helper_methods():
    # Given that I have an environment with some variables set
    data = {
        'str': 'I heard you like variables',
        'int': '42',
        'float': '3.14',
        'bool0': 'True',
        'bool1': 'true',
        'bool2': '1',
        'bool3': '2',
        'bool4': 'False',
        'bool5': 'false',
        'bool6': '0',
        'list': 'foo,bar,baz'
    }
    env = Environment(storage=data)

    # Let's retrieve things with their correct types
    assert env.get_int('int') == 42
    assert env.get_float('float') == 3.14
    assert env.get_bool('bool0') is True
    assert env.get_bool('bool1') is True
    assert env.get_bool('bool2') is True
    assert env.get_bool('bool3') is True
    assert env.get_bool('bool4') is False
    assert env.get_bool('bool5') is False
    assert env.get_bool('bool6') is False
    assert env.get_list('list') == ['foo', 'bar', 'baz']

    # Sanity checks
    with pytest.raises(ValueError):
        env.get_int('str')
    with pytest.raises(ValueError):
        env.get_float('str')
    assert env.get_bool('str') is False

    # Testing default values
    assert env.get('i-dont-exist', 'blah') == 'blah'
    assert env.get_int('i-dont-exist', 2) == 2
    assert env.get_float('i-dont-exist', 2.5) == 2.5
    assert env.get_bool('i-dont-exist', True) is True
Example #2
0
reload(sys)
sys.setdefaultencoding(ENCODING)

local_file = lambda *path: join(abspath(dirname(__file__)), *path)
module_file = lambda *path: abspath(local_file('..', *path))
project_file = lambda *path: abspath(module_file('..', *path))


env = Environment()

SELF = sys.modules[__name__]

CONNECTION_POOL_SIZE = multiprocessing.cpu_count()

LOCAL_PORT = 19842
PORT = env.get_int('PORT', LOCAL_PORT)

TEST_MODE = env.get('TEST_MODE', 'false')
OLDSPEAK_WORKDIR = env.get('OLDSPEAK_WORKDIR', '/srv/oldspeak/sandbox')
OLDSPEAK_DATADIR = env.get('OLDSPEAK_DATADIR', '/srv/oldspeak/private-data')
OLDSPEAK_PUBLICDIR = env.get('OLDSPEAK_PUBLICDIR', '/srv/oldspeak/public-data')
STATIC_FOLDER_PATH = env.get('OLDSPEAK_STATIC_FOLDER_PATH', project_file('static', 'dist'))
HTML_TEMPLATE_PATH = env.get('OLDSPEAK_HTML_TEMPLATE_PATH', project_file('static', 'templates'))
STATIC_URL_PREFIX = '/s'

HTML_TEMPLATE_PATH = project_file('static', 'templates')

BOOTSTRAP_USE_MINIFIED = True
BOOTSTRAP_SERVE_LOCAL = True
BOOTSTRAP_CDN_FORCE_SSL = True
BOOTSTRAP_QUERYSTRING_REVVING = True