def test_shelf_save(writer, filename, password): with file_cleanup(test_file): shelf = pc.EncryptedShelf(writer, filename, password) shelf["somekey"] = "somevalue" shelf.close() shelf = None # load up the old shelf shelf = pc.EncryptedShelf(writer, filename, password) assert shelf["somekey"] == "somevalue" shelf.close()
def test_shelf_in(writer, filename, password): with file_cleanup(test_file): shelf = pc.EncryptedShelf(writer, filename, password) shelf["key"] = "value" assert "key" in shelf assert "notkey" not in shelf shelf.close()
def test_shelf_get(writer, filename, password): with file_cleanup(test_file): shelf = pc.EncryptedShelf(writer, filename, password) shelf["key"] = "value" assert shelf["key"] == "value" assert shelf.get("key") == "value" assert shelf.get("notkey") is None assert shelf.get("notkey", "notvalue") == "notvalue" shelf.close()
def test_shelf_set(writer, filename, password): with file_cleanup(test_file): shelf = pc.EncryptedShelf(writer, filename, password) shelf["key"] = "value" assert shelf["key"] == "value" shelf.close()
def test_shelf_create(writer, filename, password): with file_cleanup(test_file): shelf = pc.EncryptedShelf(writer, filename, password) shelf.close()