示例#1
0
def test_ic_nesting(tmp_path):
    c = Cache(tmp_path)
    c.set_query({'hi': 'there'}, 'dude')
    with ignore_cache():
        with ignore_cache():
            pass
        assert c.lookup_query({'hi': 'there'}) is None
示例#2
0
def test_ic_enter_exit(tmp_path):
    c = Cache(tmp_path)
    c.set_query({'hi': 'there'}, 'dude')
    i = ignore_cache()
    i.__enter__()
    assert c.lookup_query({'hi': 'there'}) is None
    i.__exit__(None, None, None)
    assert c.lookup_query({'hi': 'there'}) == 'dude'
示例#3
0
def test_ic_query_cache_status(tmp_path):
    'Query status should be cached and accessed *during* a query'
    c = Cache(tmp_path)
    info = {'request_id': '111-222-333', 'key': 'bogus'}
    c.set_query_status(info)
    with ignore_cache():
        info1 = c.lookup_query_status('111-222-333')
        assert info1['key'] == 'bogus'
示例#4
0
def test_ic_files_hit(tmp_path: Path):
    'The file list should not be affected by cache ignores'
    c = Cache(tmp_path)
    f1 = tmp_path / 'f1.root'
    f2 = tmp_path / 'f2.root'
    f1.touch()
    f2.touch()
    c.set_files('1234', [('hi', f1), ('there', f2)])
    with ignore_cache():
        assert c.lookup_files('1234') == [('hi', f1), ('there', f2)]
示例#5
0
def test_ic_restore(tmp_path):
    c = Cache(tmp_path)
    c.set_query({'hi': 'there'}, 'dude')
    with ignore_cache():
        pass
    assert c.lookup_query({'hi': 'there'}) == 'dude'
示例#6
0
def test_ic_memory_hit(tmp_path):
    c = Cache(tmp_path)
    r = 10
    c.set_inmem('dude', r)
    with ignore_cache():
        assert c.lookup_inmem('dude') is None