Пример #1
0
def test_without_preload(engine, loader):
    cache = caching.FactCache(engine, 'test', loader=loader, preload=False)
    # Check the engine with the compound key, expecting None
    assert_that(engine.get('testempty'), none())
    # On get, the data is loaded in background, key returned immediately
    assert_that(cache.get('empty'), equal_to(False))

    wait_for(cache)
    assert_that(engine.get('testhit'), not_none())
Пример #2
0
    def _cache_with_mock_engine(engine, preload=True):
        def loads():
            return {str(n): 'is ' + str(n) for n in range(0, 20)}

        cache = caching.FactCache(engine,
                                  prefix='test_',
                                  loader=loads,
                                  preload=preload)
        return cache
Пример #3
0
def _cache(engine, loader, preload=True):
    return caching.FactCache(engine, 'test', loader=loader, preload=preload)
Пример #4
0
def test_with_preload(engine, loader):
    cache = caching.FactCache(engine, 'test', loader=loader, preload=True)
    wait_for(cache)
    assert_that(engine.get('testhit'), not_none())
Пример #5
0
def test_get_dict(engine, loader):
    cache = caching.FactCache(engine, 'test', loader=loader, preload=True)
    wait_for(cache)
    assert_that(cache.get('dict'), equal_to({'foo': 'bar'}))
Пример #6
0
def test_get_list(engine, loader):
    cache = caching.FactCache(engine, 'test', loader=loader, preload=True)
    wait_for(cache)
    assert_that(cache.get('list'), equal_to([1, 2, 3]))
Пример #7
0
def test_get_miss(engine, loader):
    cache = caching.FactCache(engine, 'test', loader=loader, preload=True)
    wait_for(cache)
    assert_that(cache.get('miss'), none())