Debian Codegraph @

tests/test_db.py

raw
1 import pytest
2
3 from jupyter_cache.cache.db import NbCacheRecord, Setting, create_db
4
5
6 def test_setting(tmp_path):
7 db = create_db(tmp_path)
8 Setting.set_value("a", 1, db)
9 assert Setting.get_value("a", db) == 1
10 assert Setting.get_dict(db) == {"a": 1}
11
12
13 def test_nb_record(tmp_path):
14 db = create_db(tmp_path)
15 bundle = NbCacheRecord.create_record("a", "b", db)
16 assert bundle.hashkey == "b"
17 with pytest.raises(ValueError):
18 NbCacheRecord.create_record("a", "b", db)
19 NbCacheRecord.create_record("a", "c", db, data="a")
20 assert NbCacheRecord.record_from_hashkey("b", db).uri == "a"
21 assert {b.hashkey for b in NbCacheRecord.records_from_uri("a", db)} == {"b", "c"}