示例#1
0
def test_store_init():
    Store([])
    Store([DictBackend({})])

    with pytest.raises(Exception):
        Store()
    with pytest.raises(Exception):
        Store(None)
示例#2
0
def test_store_get_setting_interpolate_value():
    store = Store([
        DictBackend(
            dict(
                environment='staging',
                secret_key='42-${environment}-secrets!',
            ))
    ])

    value = store.get_setting('secret_key')

    assert value == '42-staging-secrets!'
示例#3
0
def test_store_add_backend():
    store = Store([])

    store.add_backend(DictBackend({'environment': 'staging'}))

    assert store.get_setting('environment') == 'staging'
示例#4
0
def test_store_get_setting_interpolate_default():
    store = Store([DictBackend({'service_host': 'cool-db-server:6000'})])

    value = store.get_setting('service_url', 'https://${service_host}/db')

    assert value == 'https://cool-db-server:6000/db'
示例#5
0
def test_store_interpolate():
    store = Store([DictBackend({'environment': 'staging'})])

    s = store.interpolate('before ${environment} after')

    assert s == 'before staging after'
示例#6
0
def test_store_get_setting_missing_with_default():
    store = Store([DictBackend({})])

    value = store.get_setting('key', 'default value')

    assert value == 'default value'
示例#7
0
def test_store_get_setting_with_default():
    store = Store([DictBackend({'key': 'secrets!'})])

    value = store.get_setting('key', 'default')

    assert value == 'secrets!'