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'
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
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
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
def test_empty_wrapper(): env = EnvWrapper() assert len(list(dir(env))) == 0 assert len(list(env.keys())) == 0