MCPcopy Create free account
hub / github.com/cisco/mindmeld / test_disk_query_cache

Function test_disk_query_cache

tests/test_query_cache.py:48–61  ·  view source on GitHub ↗
(processed_queries)

Source from the content-addressed store, hash-verified

46
47
48def test_disk_query_cache(processed_queries):
49 environ = {"MM_QUERY_CACHE_IN_MEMORY": "0"}
50
51 with TemporaryDirectory() as tmpdir, patch.dict(os.environ, environ):
52 text_prep_pipeline = TextPreparationPipelineFactory.create_from_app_path(tmpdir)
53 cache = QueryCache(tmpdir, text_prep_pipeline.get_hashid())
54
55 # Verify that there is no in-memory caching
56 assert cache.memory_connection is None
57 for q in processed_queries:
58 key = QueryCache.get_key(q.domain, q.intent, q.query.text)
59 cache.put(key, q)
60 # Verify that queries are written to disk immediately
61 assert get_query_from_disk(tmpdir, key) == (q.domain, q.intent, q.query.text)
62
63
64def test_memory_query_cache(processed_queries):

Callers

nothing calls this directly

Calls 6

putMethod · 0.95
QueryCacheClass · 0.90
get_query_from_diskFunction · 0.85
create_from_app_pathMethod · 0.80
get_keyMethod · 0.80
get_hashidMethod · 0.45

Tested by

no test coverage detected