Exemple #1
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()))
Exemple #2
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') == []