mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-02 14:16:38 +00:00
test(backup): add tests for cache reloads
This commit is contained in:
parent
bc0602bfcb
commit
4757bedc4e
|
@ -567,8 +567,7 @@ class Backups:
|
|||
@staticmethod
|
||||
def forget_snapshot(snapshot: Snapshot) -> None:
|
||||
"""Deletes a snapshot from the repo and from cache"""
|
||||
Backups.provider().backupper.forget_snapshot(snapshot.id)
|
||||
Storage.delete_cached_snapshot(snapshot)
|
||||
Backups.forget_snapshots([snapshot])
|
||||
|
||||
@staticmethod
|
||||
def forget_all_snapshots():
|
||||
|
|
|
@ -472,7 +472,8 @@ def test_snapshots_caching(backups, dummy_service):
|
|||
cached_snapshots = Storage.get_cached_snapshots()
|
||||
assert len(cached_snapshots) == 1
|
||||
|
||||
Storage.delete_cached_snapshot(cached_snapshots[0])
|
||||
snap_to_uncache = cached_snapshots[0]
|
||||
Storage.delete_cached_snapshot(snap_to_uncache)
|
||||
cached_snapshots = Storage.get_cached_snapshots()
|
||||
assert len(cached_snapshots) == 0
|
||||
|
||||
|
@ -484,6 +485,35 @@ def test_snapshots_caching(backups, dummy_service):
|
|||
assert len(cached_snapshots) == 0
|
||||
|
||||
|
||||
# Storage
|
||||
def test_snapshot_cache_autoreloads(backups, dummy_service):
|
||||
Backups.back_up(dummy_service)
|
||||
|
||||
cached_snapshots = Storage.get_cached_snapshots()
|
||||
assert len(cached_snapshots) == 1
|
||||
snap_to_uncache = cached_snapshots[0]
|
||||
|
||||
Storage.delete_cached_snapshot(snap_to_uncache)
|
||||
cached_snapshots = Storage.get_cached_snapshots()
|
||||
assert len(cached_snapshots) == 0
|
||||
|
||||
# When we create a snapshot we do reload cache
|
||||
Backups.back_up(dummy_service)
|
||||
cached_snapshots = Storage.get_cached_snapshots()
|
||||
assert len(cached_snapshots) == 2
|
||||
assert snap_to_uncache in cached_snapshots
|
||||
|
||||
Storage.delete_cached_snapshot(snap_to_uncache)
|
||||
cached_snapshots = Storage.get_cached_snapshots()
|
||||
assert len(cached_snapshots) == 1
|
||||
|
||||
# When we try to delete a snapshot we cannot find in cache, it is ok and we do reload cache
|
||||
Backups.forget_snapshot(snap_to_uncache)
|
||||
cached_snapshots = Storage.get_cached_snapshots()
|
||||
assert len(cached_snapshots) == 1
|
||||
assert snap_to_uncache not in cached_snapshots
|
||||
|
||||
|
||||
def lowlevel_forget(snapshot_id):
|
||||
Backups.provider().backupper.forget_snapshot(snapshot_id)
|
||||
|
||||
|
|
Loading…
Reference in a new issue