Пример #1
0
def test_query_hit_analysis_cache_removed_query_update(tmp_path: Path):
    'If we are updating the query cache, make sure to remove an item'
    cache_loc_1 = tmp_path / 'cache1'
    cache_loc_2 = tmp_path / 'cache2'

    update_local_query_cache()

    c1 = Cache(cache_loc_1)
    c1.set_query({'hi': 'there'}, 'dude')
    c1.remove_query({'hi': 'there'})

    reset_local_query_cache()

    c2 = Cache(cache_loc_2)
    assert c2.lookup_query({'hi': 'there'}) is None
Пример #2
0
def test_query_hit_analysis_cache_removed_query_noupdate(tmp_path: Path):
    'Make sure to forget a query when we are not updating the analysis cache'
    cache_loc_1 = tmp_path / 'cache1'
    cache_loc_2 = tmp_path / 'cache2'
    cache_loc_3 = tmp_path / 'cache3'

    update_local_query_cache()

    c1 = Cache(cache_loc_1)
    c1.set_query({'hi': 'there'}, 'dude')

    reset_local_query_cache()

    c2 = Cache(cache_loc_2)
    c2.remove_query({'hi': 'there'})
    assert c2.lookup_query({'hi': 'there'}) is None

    reset_local_query_cache()

    # Make sure that the json file wasn't modified in this case!
    c3 = Cache(cache_loc_3)
    assert c3.lookup_query({'hi': 'there'}) == 'dude'
Пример #3
0
def test_query_remove(tmp_path):
    c1 = Cache(tmp_path)
    c1.set_query({'hi': 'there'}, 'dude')
    c1.remove_query({'hi': 'there'})
    assert c1.lookup_query({'hi': 'there'}) is None