test(backup): no snapshots

This commit is contained in:
Houkime 2023-02-13 11:16:35 +00:00
parent 6989dd0f7c
commit 37b747f87f
4 changed files with 20 additions and 2 deletions

View file

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

View file

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

View file

@ -1,5 +1,7 @@
import datetime
from pydantic import BaseModel
class Snapshot(BaseModel):
id: 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):
backups.back_up(test_service)
def test_no_snapshots(memory_backup):
assert memory_backup.backuper.get_snapshots("") == []