Ejemplo n.º 1
0
def test_local_storage_singleton(local_storage):
    local_storage.setup_namespace(dict(meta=1))
    keys_and_values = ((uuid.uuid4(),), b'hi')
    local_storage.put('meta', keys_and_values)
    key_range = (keys_and_values[0], keys_and_values[0])
    meta = list(local_storage.scan('meta', key_range))
    assert meta[0][1] == b'hi'
    local_storage2 = LocalStorage()
    local_storage2.setup_namespace(dict(meta=1))
    meta = list(local_storage2.scan('meta', key_range))
    assert meta[0][1] == b'hi'
Ejemplo n.º 2
0
def test_delete_namespace(local_storage):
    """Test that delete_namespace() actually clears the shared storage"""
    u = (uuid.uuid4(),)

    local_storage.setup_namespace(dict(meta=1))
    local_storage.put('meta', (u, b'hi'))
    assert list(local_storage.get('meta', u)) == [(u, b'hi')]
    local_storage.delete_namespace()

    local_storage2 = LocalStorage()
    local_storage2.setup_namespace(dict(meta=1))
    assert list(local_storage2.get('meta', u)) == [(u, None)]
Ejemplo n.º 3
0
def local_storage():
    config_yaml = """
kvlayer:
    storage_type: local
    storage_addresses: []
    namespace: test
    app_name: test
"""
    with yakonfig.defaulted_config([kvlayer], yaml=config_yaml):
        local_storage = LocalStorage()
        yield local_storage
        local_storage.delete_namespace()
Ejemplo n.º 4
0
def client():
    c = LocalStorage()
    c._data = {}
    c.setup_namespace({'t': (long,)})
    return c
Ejemplo n.º 5
0
def kvlclient():
    c = LocalStorage(app_name='a', namespace='n')
    c._data = {}
    return c
Ejemplo n.º 6
0
def kvlclient():
    c = LocalStorage(app_name='a', namespace='n')
    c._data = {}
    return c