()
| 610 | |
| 611 | |
| 612 | def 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 | |
| 633 | def test_tinydb_is_iterable(db: TinyDB): |
nothing calls this directly
no test coverage detected
searching dependent graphs…