MCPcopy
hub / github.com/caronc/apprise / test_persistent_storage_auto_mode

Function test_persistent_storage_auto_mode

tests/test_persistent_store.py:212–247  ·  view source on GitHub ↗

Persistent Storage Auto Write Testing.

(tmpdir)

Source from the content-addressed store, hash-verified

210
211
212def test_persistent_storage_auto_mode(tmpdir):
213 """Persistent Storage Auto Write Testing."""
214 namespace = "abc"
215 # Create ourselves an attachment object
216 pc = PersistentStore(
217 namespace=namespace, path=str(tmpdir), mode=PersistentStoreMode.AUTO
218 )
219
220 pc.write(b"test")
221 with mock.patch("os.unlink", side_effect=FileNotFoundError()):
222 assert pc.delete(all=True) is True
223
224 # Create a temporary file we can delete
225 with open(os.path.join(pc.path, pc.temp_dir, "test.file"), "wb") as fd:
226 fd.write(b"data")
227
228 # Delete just the temporary files
229 assert pc.delete(temp=True) is True
230
231 # Delete just the temporary files
232 # Create a cache entry and delete it
233 assert pc.set("key", "value") is True
234 pc.write(b"test")
235 assert pc.delete(cache=True) is True
236 # Verify our data entry wasn't removed
237 assert pc.read() == b"test"
238 # But our cache was
239 assert pc.get("key") is None
240
241 # A reverse of the above... create a cache an data variable and
242 # Clear the data; make sure our cache is still there
243 assert pc.set("key", "value") is True
244 assert pc.write(b"test", key="iokey") is True
245 assert pc.delete("iokey") is True
246 assert pc.get("key") == "value"
247 assert pc.read("iokey") is None
248
249
250def test_persistent_storage_flush_mode(tmpdir):

Callers

nothing calls this directly

Calls 8

writeMethod · 0.95
deleteMethod · 0.95
setMethod · 0.95
readMethod · 0.95
getMethod · 0.95
PersistentStoreClass · 0.90
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…