def test_filter_env_non_dict_in_match(): """ ~xxx syntax: should contain dict """ yc = YamlConfig(env='foo') with pytest.raises(TypeError): yc.filter_env({'~foo': 'bar'})
def test_filter_env_non_dict_in_match(): """ ~xxx syntax: should contain dict """ yc = YamlConfig(env='foo') with pytest.raises(TypeError): yc.filter_env({ '~foo': 'bar' })
def test_filter_env_non_dict(): """ pass through non-dict elements """ yc = YamlConfig(env='xx') result = yc.filter_env('foo') assert result == 'foo'
def test_filter_env_remove(): """ ~xxx syntax: remove elements that not match """ yc = YamlConfig(env='xx') result = yc.filter_env({'~foo': 'bar'}) assert result == {}
def test_filter_env_remove(): """ ~xxx syntax: remove elements that not match """ yc = YamlConfig(env='xx') result = yc.filter_env({ '~foo': 'bar' }) assert result == {}
def test_filter_env_dict_no_env(): """ pass through dict elements without ~ """ yc = YamlConfig(env='xx') flexmock(yc).should_call('filter_env').with_args({'foo': 'bar'}).once() flexmock(yc).should_call('filter_env').with_args('bar').once() result = yc.filter_env({'foo': 'bar'}) assert result == {'foo': 'bar'}
def test_filter_env_keep(): """ ~xxx syntax: keep elements that match """ yc = YamlConfig(env='foo') flexmock(yc).should_call('filter_env').with_args({'~foo': {'bar': 'baz'}}).once().and_return({'bar': 'baz'}) flexmock(yc).should_call('filter_env').with_args({'bar': 'baz'}).once().and_return({'bar': 'baz'}) flexmock(yc).should_call('filter_env').with_args('baz').once().and_return('baz') result = yc.filter_env({ '~foo': {'bar': 'baz'} }) assert result == {'bar': 'baz'}
def test_filter_env_keep(): """ ~xxx syntax: keep elements that match """ yc = YamlConfig(env='foo') flexmock(yc).should_call('filter_env').with_args({ '~foo': { 'bar': 'baz' } }).once().and_return({'bar': 'baz'}) flexmock(yc).should_call('filter_env').with_args({ 'bar': 'baz' }).once().and_return({'bar': 'baz'}) flexmock(yc).should_call('filter_env').with_args('baz').once().and_return( 'baz') result = yc.filter_env({'~foo': {'bar': 'baz'}}) assert result == {'bar': 'baz'}