Пример #1
0
def test_exception_on_source_for_missing_key():
    d = ConfigTree(layers=['inner', 'outer'])
    d._read_dict({'test_key': 'test_value'},
                 layer='inner',
                 source='initial_load')

    with pytest.raises(KeyError) as excinfo:
        d.metadata('missing_key')
    assert 'missing_key' in str(excinfo.value)
Пример #2
0
def test_source_metadata():
    d = ConfigTree(layers=['inner', 'outer'])
    d.update({'test_key': 'test_value'}, layer='inner', source='initial_load')
    d.update({'test_key': 'test_value2'}, layer='outer', source='update')

    assert d.metadata('test_key') == [{
        'layer': 'inner',
        'source': 'initial_load',
        'value': 'test_value'
    }, {
        'layer': 'outer',
        'source': 'update',
        'value': 'test_value2'
    }]
Пример #3
0
def test_exception_on_source_for_missing_key():
    d = ConfigTree(layers=['inner', 'outer'])
    d.update({'test_key': 'test_value'}, layer='inner', source='initial_load')

    with pytest.raises(ConfigurationKeyError):
        d.metadata('missing_key')