예제 #1
0
def test_cache_inmem_simple():
    cache = RequestCache(3)
    req = gen_reqs(1)[0]
    req.reqid = None
    cache.add(req)
    assert req.reqid[0] == "m"
    g = yield cache.get(req.reqid)
    assert req == g
예제 #2
0
def test_cache_inmem_simple():
    cache = RequestCache(3)
    req = gen_reqs(1)[0]
    req.reqid = None
    cache.add(req)
    assert req.reqid[0] == 'm'
    g = yield cache.get(req.reqid)
    assert req == g
예제 #3
0
def test_req_ids():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    cache.add(reqs[0])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert cache.req_ids() == ['4', '3', '2', '1']
예제 #4
0
def test_req_ids():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    cache.add(reqs[0])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert cache.req_ids() == ['4', '3', '2', '1']
예제 #5
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
예제 #6
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
예제 #7
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
예제 #8
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
예제 #9
0
def test_req_ids_unmangled():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    reqs[0].unmangled = reqs[4]
    cache.add(reqs[0])
    cache.add(reqs[4])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert cache.req_ids() == ['4', '3', '2', '1']
    assert cache.req_ids(include_unmangled=True) == ['4', '3', '2', '5', '1']
예제 #10
0
def test_req_ids_unmangled():
    reqs = gen_reqs(5)
    cache = RequestCache(3)
    reqs[0].unmangled = reqs[4]
    cache.add(reqs[0])
    cache.add(reqs[4])
    cache.add(reqs[1])
    cache.add(reqs[2])
    cache.add(reqs[3])
    assert cache.req_ids() == ['4', '3', '2', '1']
    assert cache.req_ids(include_unmangled=True) == ['4', '3', '2', '5', '1']
예제 #11
0
def test_cache_simple():
    reqs = gen_reqs(5)
    cache = RequestCache(5)
    cache.add(reqs[0])
    g = yield cache.get('1')
    assert g == reqs[0]
예제 #12
0
def test_cache_simple():
    reqs = gen_reqs(5)
    cache = RequestCache(5)
    cache.add(reqs[0])
    g = yield cache.get("1")
    assert g == reqs[0]