MCPcopy
hub / github.com/msiemens/tinydb / test_query_cache

Function test_query_cache

tests/test_tinydb.py:612–630  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

610
611
612def test_query_cache():
613 db = TinyDB(storage=MemoryStorage)
614 db.insert_multiple([
615 {'name': 'foo', 'value': 42},
616 {'name': 'bar', 'value': -1337}
617 ])
618
619 query = where('value') > 0
620
621 results = db.search(query)
622 assert len(results) == 1
623
624 # Modify the db instance to not return any results when
625 # bypassing the query cache
626 db._tables[db.table(db.default_table_name).name]._read_table = lambda: {}
627
628 # Make sure we got an independent copy of the result list
629 results.extend([1])
630 assert db.search(query) == [{'name': 'foo', 'value': 42}]
631
632
633def test_tinydb_is_iterable(db: TinyDB):

Callers

nothing calls this directly

Calls 5

tableMethod · 0.95
TinyDBClass · 0.90
whereFunction · 0.90
insert_multipleMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…