mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 09:16:51 +00:00
test(backup): provider class selection
This commit is contained in:
parent
7d76b74dbc
commit
9097ba02d7
|
@ -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]
|
|
@ -3,4 +3,4 @@ from selfprivacy_api.backup.restic_backuper import ResticBackuper
|
||||||
|
|
||||||
|
|
||||||
class Backblaze(AbstractBackupProvider):
|
class Backblaze(AbstractBackupProvider):
|
||||||
backuper = ResticBackuper()
|
backuper = ResticBackuper("--b2-account", "--b2-key", "b2")
|
||||||
|
|
|
@ -11,3 +11,7 @@ class AbstractBackupProvider(ABC):
|
||||||
@property
|
@property
|
||||||
def backuper(self) -> AbstractBackuper:
|
def backuper(self) -> AbstractBackuper:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def __init__(self, login, key):
|
||||||
|
self.login = login
|
||||||
|
self.key = key
|
||||||
|
|
11
tests/test_graphql/test_backup.py
Normal file
11
tests/test_graphql/test_backup.py
Normal 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
|
Loading…
Reference in a new issue