test(backup): no snapshots

This commit is contained in:
Houkime 2023-02-13 11:16:35 +00:00 committed by Inex Code
parent 83b24f5fcd
commit e156e9cd58
4 changed files with 20 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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("") == []