Example #1
0
def test_items(os_env):
    env = EnvWrapper(VAR1=EnvVar(), VAR2=EnvVar())
    os_env['VAR1'] = 'foo'
    os_env['VAR2'] = 'bar'
    d = dict(env.items())
    assert set(env.keys()) == set(d.keys())
    assert d['VAR1'] == 'foo'
    assert d['VAR2'] == 'bar'
Example #2
0
def test_collect():
    env = EnvWrapper(VAR=EnvVar(),
                     PREFIXED=EnvVar(prefix='FOO_'),
                     BUNDLED=EnvVar(bundle='GROUP'),
                     PROXIED=EnvVar(proxy='YADA'))
    d = env.collect()
    expected_os_env = {'VAR', 'FOO_PREFIXED', 'BUNDLED', 'YADA'}
    assert set(d.keys()) == expected_os_env
    expected_app_schema = {'VAR', 'PREFIXED', 'GROUP', 'BUNDLED', 'PROXIED'}
    assert set(env.keys()) == expected_app_schema
Example #3
0
def test_prefix(os_env):
    env = EnvWrapper(VAR=EnvVar(prefix='APP_'))
    os_env['APP_VAR'] = 'foo'
    assert 'VAR' in env.keys()
    assert 'APP_VAR' not in env
Example #4
0
def test_len_keys_and_dir():
    env = EnvWrapper(VAR1=EnvVar(), VAR2=EnvVar())
    assert set(env.keys()) == set(dir(env)) == {'VAR1', 'VAR2'}
    assert len(env) == len(dir(env)) == len(list(env.keys())) == 2
Example #5
0
def test_empty_wrapper():
    env = EnvWrapper()
    assert len(list(dir(env))) == 0
    assert len(list(env.keys())) == 0