mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
feat(backups): return proper snapshot structs when listing
This commit is contained in:
parent
a0a32a7f37
commit
e56907f2cd
|
@ -128,9 +128,14 @@ class ResticBackuper(AbstractBackuper):
|
|||
|
||||
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
||||
"""Get all snapshots from the repo"""
|
||||
# No transformation for now
|
||||
snapshots = []
|
||||
for snapshot in self._load_snapshots(repo_name):
|
||||
for restic_snapshot in self._load_snapshots(repo_name):
|
||||
snapshot = Snapshot(
|
||||
id=restic_snapshot["short_id"],
|
||||
created_at=restic_snapshot["time"],
|
||||
service_name=repo_name,
|
||||
)
|
||||
|
||||
snapshots.append(snapshot)
|
||||
return snapshots
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ from os import makedirs
|
|||
|
||||
from selfprivacy_api.services.test_service import DummyService
|
||||
|
||||
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||
|
||||
from selfprivacy_api.backup import Backups
|
||||
import selfprivacy_api.backup.providers as providers
|
||||
from selfprivacy_api.backup.providers import AbstractBackupProvider
|
||||
|
@ -100,4 +102,8 @@ def test_no_repo(memory_backup):
|
|||
|
||||
def test_one_snapshot(backups, dummy_service):
|
||||
backups.back_up(dummy_service)
|
||||
assert len(backups.get_snapshots(dummy_service)) == 1
|
||||
|
||||
snaps = backups.get_snapshots(dummy_service)
|
||||
assert len(snaps) == 1
|
||||
snap = snaps[0]
|
||||
assert snap.service_name == dummy_service.get_id()
|
||||
|
|
Loading…
Reference in a new issue