def test_dictionary_style_access(): d = ConfigTree() d.test_key = 'test_value' d['test_key2'] = 'test_value2' assert d['test_key'] == 'test_value' assert d.test_key2 == 'test_value2'
def test_outer_layer_set(): d = ConfigTree(layers=['inner', 'outer']) d.set_with_metadata('test_key', 'test_value', 'inner') d.set_with_metadata('test_key', 'test_value2', 'outer') d.test_key = 'test_value3' assert d.test_key == 'test_value3'
def test_single_layer(): d = ConfigTree() d.test_key = 'test_value' d.test_key2 = 'test_value2' assert d.test_key == 'test_value' assert d.test_key2 == 'test_value2' d.test_key2 = 'test_value3' assert d.test_key2 == 'test_value3' assert d.test_key == 'test_value'
def test_outer_layer_set(): d = ConfigTree(layers=['inner', 'outer']) d._set_with_metadata('test_key', 'test_value', 'inner', source=None) d._set_with_metadata('test_key', 'test_value3', layer=None, source=None) assert d.test_key == 'test_value3' assert d['test_key'] == 'test_value3' d = ConfigTree(layers=['inner', 'outer']) d._set_with_metadata('test_key', 'test_value', 'inner', source=None) d.test_key = 'test_value3' assert d.test_key == 'test_value3' assert d['test_key'] == 'test_value3' d = ConfigTree(layers=['inner', 'outer']) d._set_with_metadata('test_key', 'test_value', 'inner', source=None) d['test_key'] = 'test_value3' assert d.test_key == 'test_value3' assert d['test_key'] == 'test_value3'
def test_get_missing(): d = ConfigTree() d.test_key = 'test_value' # Missing keys should be empty containers assert len(d.missing_key) == 0