test(backup): provider class selection

This commit is contained in:
Houkime 2023-02-01 11:58:55 +00:00
parent 19ad9a5113
commit 327ad8171f
4 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,11 @@
from selfprivacy_api.graphql.queries.providers import BackupProvider
from selfprivacy_api.backup.providers.provider import AbstractBackupProvider
from selfprivacy_api.backup.providers.backblaze import Backblaze
PROVIDER_MAPPING = {
BackupProvider.BACKBLAZE: Backblaze
}
def get_provider(provider_type : BackupProvider) -> AbstractBackupProvider:
return PROVIDER_MAPPING[provider_type]

View file

@ -3,4 +3,4 @@ from selfprivacy_api.backup.restic_backuper import ResticBackuper
class Backblaze(AbstractBackupProvider):
backuper = ResticBackuper()
backuper = ResticBackuper("--b2-account", "--b2-key", "b2")

View file

@ -11,3 +11,7 @@ class AbstractBackupProvider(ABC):
@property
def backuper(self) -> AbstractBackuper:
raise NotImplementedError
def __init__(self, login, key):
self.login = login
self.key = key

View file

@ -0,0 +1,11 @@
import selfprivacy_api.backup.providers as providers
from selfprivacy_api.backup.providers import AbstractBackupProvider
from selfprivacy_api.backup.providers.backblaze import Backblaze
from selfprivacy_api.graphql.queries.providers import BackupProvider
def test_select_backend():
provider = providers.get_provider(BackupProvider.BACKBLAZE)
assert provider is not None
assert provider == Backblaze