mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-27 22:41:28 +00:00
feat(backups): return proper snapshot structs when listing
This commit is contained in:
parent
de12685d3d
commit
cc09e933ed
|
@ -128,9 +128,14 @@ class ResticBackuper(AbstractBackuper):
|
||||||
|
|
||||||
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
||||||
"""Get all snapshots from the repo"""
|
"""Get all snapshots from the repo"""
|
||||||
# No transformation for now
|
|
||||||
snapshots = []
|
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)
|
snapshots.append(snapshot)
|
||||||
return snapshots
|
return snapshots
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ from os import makedirs
|
||||||
|
|
||||||
from selfprivacy_api.services.test_service import DummyService
|
from selfprivacy_api.services.test_service import DummyService
|
||||||
|
|
||||||
|
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||||
|
|
||||||
from selfprivacy_api.backup import Backups
|
from selfprivacy_api.backup import Backups
|
||||||
import selfprivacy_api.backup.providers as providers
|
import selfprivacy_api.backup.providers as providers
|
||||||
from selfprivacy_api.backup.providers import AbstractBackupProvider
|
from selfprivacy_api.backup.providers import AbstractBackupProvider
|
||||||
|
@ -100,4 +102,8 @@ def test_no_repo(memory_backup):
|
||||||
|
|
||||||
def test_one_snapshot(backups, dummy_service):
|
def test_one_snapshot(backups, dummy_service):
|
||||||
backups.back_up(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