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

Function test_json_read

tests/test_storages.py:82–97  ·  view source on GitHub ↗

r"""Open a database only for reading

(tmpdir)

Source from the content-addressed store, hash-verified

80
81
82def test_json_read(tmpdir):
83 r"""Open a database only for reading"""
84 path = str(tmpdir.join('test.db'))
85 with pytest.raises(FileNotFoundError):
86 db = TinyDB(path, storage=JSONStorage, access_mode='r')
87 # Create small database
88 db = TinyDB(path, storage=JSONStorage)
89 db.insert({'b': 1})
90 db.insert({'a': 1})
91 db.close()
92 # Access in read mode
93 db = TinyDB(path, storage=JSONStorage, access_mode='r')
94 assert db.get(where('a') == 1) == {'a': 1} # reading is fine
95 with pytest.raises(IOError):
96 db.insert({'c': 1}) # writing is not
97 db.close()
98
99
100def test_create_dirs():

Callers

nothing calls this directly

Calls 5

closeMethod · 0.95
TinyDBClass · 0.90
whereFunction · 0.90
insertMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…