mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
test(backup): no snapshots
This commit is contained in:
parent
83b24f5fcd
commit
e156e9cd58
|
@ -1,4 +1,7 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from typing import List
|
||||
|
||||
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||
|
||||
|
||||
class AbstractBackuper(ABC):
|
||||
|
@ -8,3 +11,8 @@ class AbstractBackuper(ABC):
|
|||
@abstractmethod
|
||||
def start_backup(self, folder: str, repo_name: str):
|
||||
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 json
|
||||
|
||||
from typing import List
|
||||
|
||||
from selfprivacy_api.backup.backuper import AbstractBackuper
|
||||
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||
|
||||
|
||||
class ResticBackuper(AbstractBackuper):
|
||||
|
@ -107,10 +110,11 @@ class ResticBackuper(AbstractBackuper):
|
|||
self.error_message = output
|
||||
return []
|
||||
|
||||
def get_snapshots(self):
|
||||
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():
|
||||
for snapshot in self._load_snapshots(repo_name):
|
||||
snapshots.append(snapshot)
|
||||
return snapshots
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import datetime
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Snapshot(BaseModel):
|
||||
id: str
|
||||
service_name: str
|
||||
|
|
|
@ -57,3 +57,7 @@ def test_backup_simple(test_service, memory_backup):
|
|||
|
||||
def test_backup_service(test_service, backups):
|
||||
backups.back_up(test_service)
|
||||
|
||||
|
||||
def test_no_snapshots(memory_backup):
|
||||
assert memory_backup.backuper.get_snapshots("") == []
|
||||
|
|
Loading…
Reference in a new issue