コード例 #1
0
def test_compare_and_str(tmp_path):
    p = tmp_path / "test.json"
    fstore = persist.FileDataStore(p)
    mstore = persist.MemoryDataStore()
    assert fstore != mstore
    assert fstore == fstore
    assert mstore == mstore
    str(fstore)
    str(mstore)
コード例 #2
0
def test_datastoremanager_create_add(tmp_path):
    p = tmp_path / "test.json"
    fstore = persist.FileDataStore(p)
    mstore = persist.MemoryDataStore()
    dsm = persist.DataStoreManager()
    assert dsm.add("memory", mstore)
    assert not dsm.add("memory", mstore)  # idempotence
    assert dsm.add("file", fstore)
    assert not dsm.add("file", fstore)  # idempotence
    assert dsm.add("file", mstore)  # changed type
    assert dsm.add("file", fstore)  # changed type again
    assert not dsm.add("file", fstore)  # idempotence
コード例 #3
0
def test_datastoremanager_save_load(tmp_path):
    dsm = persist.DataStoreManager()
    dsm.add("foo", persist.FileDataStore(tmp_path / "test.json"))
    dsm.add("bar", persist.MemoryDataStore())
    _save_and_load_data_dsm("foo", dsm)
    _save_and_load_data_dsm("bar", dsm)
コード例 #4
0
def test_file_data_store(tmp_path):
    p = tmp_path / "test.json"
    store = persist.FileDataStore(p)
    _save_and_load_data(store)