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

Function test_doc_ids_json

tests/test_tinydb.py:498–527  ·  view source on GitHub ↗

Regression test for issue #45

(tmpdir)

Source from the content-addressed store, hash-verified

496
497
498def test_doc_ids_json(tmpdir):
499 """
500 Regression test for issue #45
501 """
502
503 path = str(tmpdir.join('db.json'))
504
505 with TinyDB(path) as _db:
506 _db.drop_tables()
507 assert _db.insert({'int': 1, 'char': 'a'}) == 1
508 assert _db.insert({'int': 1, 'char': 'a'}) == 2
509
510 _db.drop_tables()
511 assert _db.insert_multiple([{'int': 1, 'char': 'a'},
512 {'int': 1, 'char': 'b'},
513 {'int': 1, 'char': 'c'}]) == [1, 2, 3]
514
515 assert _db.contains(doc_id=1)
516 assert _db.contains(doc_id=2)
517 assert not _db.contains(doc_id=88)
518
519 _db.update({'int': 2}, doc_ids=[1, 2])
520 assert _db.count(where('int') == 2) == 2
521
522 el = _db.all()[0]
523 assert _db.get(doc_id=el.doc_id) == el
524 assert _db.get(doc_id=float('NaN')) is None
525
526 _db.remove(doc_ids=[1, 2])
527 assert len(_db) == 1
528
529
530def test_insert_string(tmpdir):

Callers

nothing calls this directly

Calls 11

TinyDBClass · 0.90
whereFunction · 0.90
drop_tablesMethod · 0.80
insertMethod · 0.80
insert_multipleMethod · 0.80
containsMethod · 0.80
countMethod · 0.80
removeMethod · 0.80
updateMethod · 0.45
allMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…