示例#1
0
    def test_save(self, shelve_path):
        assert not shelve_path.exists()

        shelve = ShelveStore(str(shelve_path), FAKE_SESSION_ID)
        shelve["shelve_path"] = shelve_path
        shelve.save()

        assert (shelve_path / FAKE_SESSION_ID).is_dir()

        reloaded = ShelveStore(str(shelve_path), FAKE_SESSION_ID)
        assert reloaded == {"shelve_path": shelve_path}
示例#2
0
    def test_update(self, shelve_path):
        shelve = ShelveStore(str(shelve_path), FAKE_SESSION_ID)
        shelve["shelve_path"] = shelve_path
        shelve.save()

        shelve.update(new_key="new_value")
        del shelve["shelve_path"]
        reloaded = ShelveStore(str(shelve_path), FAKE_SESSION_ID)
        assert reloaded == {"shelve_path": shelve_path}  # changes not saved yet

        shelve.save()
        reloaded = ShelveStore(str(shelve_path), FAKE_SESSION_ID)
        assert reloaded == {"new_key": "new_value"}
示例#3
0
 def test_empty(self, shelve_path):
     shelve = ShelveStore(str(shelve_path), FAKE_SESSION_ID)
     assert shelve == dict()
     assert shelve._location == shelve_path / FAKE_SESSION_ID / "store"
     assert not shelve_path.exists()