mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 07:21:27 +00:00
feature(backups): feature(backups): return a snapshot from start_backup
This commit is contained in:
parent
9a94f7624e
commit
9d5335f62c
|
@ -223,6 +223,7 @@ class Backups:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
Jobs.update(job, status=JobStatus.FINISHED)
|
Jobs.update(job, status=JobStatus.FINISHED)
|
||||||
|
return snapshot
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def init_repo(service: Optional[Service] = None):
|
def init_repo(service: Optional[Service] = None):
|
||||||
|
|
|
@ -104,7 +104,7 @@ class Storage:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_cached_snapshot_by_id(snapshot_id: str) -> Optional[Snapshot]:
|
def get_cached_snapshot_by_id(snapshot_id: str) -> Optional[Snapshot]:
|
||||||
key = redis.keys(REDIS_SNAPSHOTS_PREFIX + snapshot_id)
|
key = REDIS_SNAPSHOTS_PREFIX + snapshot_id
|
||||||
if not redis.exists(key):
|
if not redis.exists(key):
|
||||||
return None
|
return None
|
||||||
return hash_as_model(redis, key, Snapshot)
|
return hash_as_model(redis, key, Snapshot)
|
||||||
|
|
|
@ -243,6 +243,18 @@ def assert_job_had_progress(job_type):
|
||||||
assert len(Jobs.progress_updates(job)) > 0
|
assert len(Jobs.progress_updates(job)) > 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_snapshots_by_id(backups, dummy_service):
|
||||||
|
snap1 = Backups.back_up(dummy_service)
|
||||||
|
snap2 = Backups.back_up(dummy_service)
|
||||||
|
snap3 = Backups.back_up(dummy_service)
|
||||||
|
|
||||||
|
assert snap2.id is not None
|
||||||
|
assert snap2.id != ""
|
||||||
|
|
||||||
|
assert len(Backups.get_snapshots(dummy_service)) == 3
|
||||||
|
assert Backups.get_snapshot_by_id(snap2.id).id == snap2.id
|
||||||
|
|
||||||
|
|
||||||
def test_backup_service_task(backups, dummy_service):
|
def test_backup_service_task(backups, dummy_service):
|
||||||
handle = start_backup(dummy_service)
|
handle = start_backup(dummy_service)
|
||||||
handle(blocking=True)
|
handle(blocking=True)
|
||||||
|
|
Loading…
Reference in a new issue