mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-28 06:51:28 +00:00
test(backup): provider class selection
This commit is contained in:
parent
19ad9a5113
commit
327ad8171f
|
@ -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):
|
||||
backuper = ResticBackuper()
|
||||
backuper = ResticBackuper("--b2-account", "--b2-key", "b2")
|
||||
|
|
|
@ -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
|
||||
|
|
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