mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-28 06:51:28 +00:00
test(backup): no snapshots
This commit is contained in:
parent
6989dd0f7c
commit
37b747f87f
|
@ -1,4 +1,7 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||||
|
|
||||||
|
|
||||||
class AbstractBackuper(ABC):
|
class AbstractBackuper(ABC):
|
||||||
|
@ -8,3 +11,8 @@ class AbstractBackuper(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def start_backup(self, folder: str, repo_name: str):
|
def start_backup(self, folder: str, repo_name: str):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
||||||
|
"""Get all snapshots from the repo"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from selfprivacy_api.backup.backuper import AbstractBackuper
|
from selfprivacy_api.backup.backuper import AbstractBackuper
|
||||||
|
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||||
|
|
||||||
|
|
||||||
class ResticBackuper(AbstractBackuper):
|
class ResticBackuper(AbstractBackuper):
|
||||||
|
@ -107,10 +110,11 @@ class ResticBackuper(AbstractBackuper):
|
||||||
self.error_message = output
|
self.error_message = output
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_snapshots(self):
|
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
||||||
|
"""Get all snapshots from the repo"""
|
||||||
# No transformation for now
|
# No transformation for now
|
||||||
snapshots = []
|
snapshots = []
|
||||||
for snapshot in self._load_snapshots():
|
for snapshot in self._load_snapshots(repo_name):
|
||||||
snapshots.append(snapshot)
|
snapshots.append(snapshot)
|
||||||
return snapshots
|
return snapshots
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import datetime
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class Snapshot(BaseModel):
|
class Snapshot(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
service_name: str
|
service_name: str
|
||||||
|
|
|
@ -57,3 +57,7 @@ def test_backup_simple(test_service, memory_backup):
|
||||||
|
|
||||||
def test_backup_service(test_service, backups):
|
def test_backup_service(test_service, backups):
|
||||||
backups.back_up(test_service)
|
backups.back_up(test_service)
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_snapshots(memory_backup):
|
||||||
|
assert memory_backup.backuper.get_snapshots("") == []
|
||||||
|
|
Loading…
Reference in a new issue