Exemplo n.º 1
0
def test_glue_tries_to_get_from_other_backends_if_gets_empty_list():
    mem = MemoryBackend(9)
    csv = CSVBackend()
    glue = GlueBackend(mem, csv)
    glue.set('key', t, 9)
    mem.clear()  # say, machine was rebooted, but csv files are still there
    assert glue.get('key')[0][1] == 9
Exemplo n.º 2
0
def test_glue_failure():
    glue = GlueBackend(BinaryBackend())
    glue.set('key', t, 1)
    with raises(BackendError):
        glue.set('key', t, 'I')
Exemplo n.º 3
0
def test_glue_backend_dispatch():
    mem = MemoryBackend(1)
    bin = BinaryBackend()
    csv = CSVBackend()
    glue = GlueBackend(mem, bin, csv)
    glue.set('key', t, 1)
    assert glue.get('key')[0][1] == 1
    assert glue.get('key') == mem.get('key') == csv.get('key')
    glue.clear()
    glue.set('key', t, 'value')
    assert glue.get('key')[0][1] == 'value'
    assert glue.get('key') == mem.get('key') == csv.get('key')
    assert bin.get('key') == []