Пример #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
Пример #2
0
def test_memory_backend_errors():
    backend = MemoryBackend(1)  # seconds
    backend.set('key', t, 'value')
    [[time, value]] = backend.get('key',
            start=datetime.now() - timedelta(seconds=0.5),
            end=datetime.now())
    assert type(time) is datetime
    assert value == 'value'
    with raises(BackendError):
        print(backend.get('key',
            start=datetime.now() - timedelta(seconds=1.5),
            end=datetime.now()))
Пример #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') == []