def test_expose_sources_for_manipulation(): source1 = DictSource({'a': 1, 'b': {'c': 2}}) source2 = DictSource({'a': 10, 'b': {'c': 20}}) source3 = DictSource({'x': 6, 'b': {'y': 7}}) config = StackedConfig() assert config.dump() == {} config.source_list.append(source1) assert config == source1 config.source_list.append(source2) assert config == source2 config.source_list.insert(0, source3) assert config.dump() == {'a': 10, 'b': {'c': 20, 'y': 7}, 'x': 6}
def test_set_keychain(): config = StackedConfig(DictSource({'a': { 'b': { 'c': 2 } }}), keychain=('a', 'b')) assert config.dump() == {'c': 2}
def test_stacked_dump(): config = StackedConfig(DictSource({ 'a': 1, 'b': { 'c': 2 } }), DictSource({'a': '10'}), DictSource({ 'x': 6, 'b': { 'y': 7 } })) assert config.dump() == {'a': '10', 'b': {'c': 2, 'y': 7}, 'x': 6}
def test_use_dictsource_on_empty_stacked_config(): config = StackedConfig() assert config.dump() == {}