예제 #1
0
def test_cache_evict():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    cache.add(reqs[0])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert not cache.check(reqs[0].reqid)
    assert cache.check(reqs[1].reqid)
    assert cache.check(reqs[2].reqid)
    assert cache.check(reqs[3].reqid)

    # Testing the implementation
    assert reqs[0].reqid not in cache._cached_reqs
    assert reqs[1].reqid in cache._cached_reqs
    assert reqs[2].reqid in cache._cached_reqs
    assert reqs[3].reqid in cache._cached_reqs
예제 #2
0
def test_cache_evict():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    cache.add(reqs[0])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert not cache.check(reqs[0].reqid)
    assert cache.check(reqs[1].reqid)
    assert cache.check(reqs[2].reqid)
    assert cache.check(reqs[3].reqid)

    # Testing the implementation
    assert reqs[0].reqid not in cache._cached_reqs
    assert reqs[1].reqid in cache._cached_reqs
    assert reqs[2].reqid in cache._cached_reqs
    assert reqs[3].reqid in cache._cached_reqs
예제 #3
0
def test_cache_inmem_evict():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    reqs[0].reqid = None
    reqs[1].reqid = None
    reqs[2].reqid = None
    reqs[3].reqid = None
    cache.add(reqs[0])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert not cache.check(reqs[0].reqid)
    assert cache.check(reqs[1].reqid)
    assert cache.check(reqs[2].reqid)
    assert cache.check(reqs[3].reqid)

    # Testing the implementation
    assert reqs[0] in cache.inmem_reqs
    assert reqs[1] in cache.inmem_reqs
    assert reqs[2] in cache.inmem_reqs
    assert reqs[3] in cache.inmem_reqs
예제 #4
0
def test_cache_inmem_evict():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    reqs[0].reqid = None
    reqs[1].reqid = None
    reqs[2].reqid = None
    reqs[3].reqid = None
    cache.add(reqs[0])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert not cache.check(reqs[0].reqid)
    assert cache.check(reqs[1].reqid)
    assert cache.check(reqs[2].reqid)
    assert cache.check(reqs[3].reqid)

    # Testing the implementation
    assert reqs[0] in RequestCache.inmem_reqs
    assert reqs[1] in RequestCache.inmem_reqs
    assert reqs[2] in RequestCache.inmem_reqs
    assert reqs[3] in RequestCache.inmem_reqs