mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-12 21:53:16 +00:00
refactor(backups): make redis and json provider related lowlevels private
This commit is contained in:
parent
71eeed926d
commit
1593474dc1
|
@ -63,12 +63,12 @@ class Backups:
|
|||
|
||||
@staticmethod
|
||||
def _lookup_provider() -> AbstractBackupProvider:
|
||||
redis_provider = Backups.load_provider_redis()
|
||||
redis_provider = Backups._load_provider_redis()
|
||||
if redis_provider is not None:
|
||||
return redis_provider
|
||||
|
||||
try:
|
||||
json_provider = Backups.load_provider_json()
|
||||
json_provider = Backups._load_provider_json()
|
||||
except FileNotFoundError:
|
||||
json_provider = None
|
||||
|
||||
|
@ -100,7 +100,7 @@ class Backups:
|
|||
)
|
||||
|
||||
@staticmethod
|
||||
def load_provider_redis() -> Optional[AbstractBackupProvider]:
|
||||
def _load_provider_redis() -> Optional[AbstractBackupProvider]:
|
||||
provider_model = Storage.load_provider()
|
||||
if provider_model is None:
|
||||
return None
|
||||
|
@ -113,7 +113,7 @@ class Backups:
|
|||
)
|
||||
|
||||
@staticmethod
|
||||
def load_provider_json() -> Optional[AbstractBackupProvider]:
|
||||
def _load_provider_json() -> Optional[AbstractBackupProvider]:
|
||||
with ReadUserData() as user_data:
|
||||
provider_dict = {
|
||||
"provider": "",
|
||||
|
@ -143,7 +143,7 @@ class Backups:
|
|||
return None
|
||||
|
||||
@staticmethod
|
||||
def reset_provider_json() -> None:
|
||||
def _reset_provider_json() -> None:
|
||||
with WriteUserData() as user_data:
|
||||
if "backblaze" in user_data.keys():
|
||||
del user_data["backblaze"]
|
||||
|
@ -156,7 +156,7 @@ class Backups:
|
|||
Storage.reset()
|
||||
if reset_json:
|
||||
try:
|
||||
Backups.reset_provider_json()
|
||||
Backups._reset_provider_json()
|
||||
except FileNotFoundError:
|
||||
# if there is no userdata file, we do not need to reset it
|
||||
pass
|
||||
|
|
|
@ -475,7 +475,7 @@ def test_provider_storage(backups_backblaze):
|
|||
assert provider.key == "KEY"
|
||||
|
||||
Storage.store_provider(provider)
|
||||
restored_provider = Backups.load_provider_redis()
|
||||
restored_provider = Backups._load_provider_redis()
|
||||
assert isinstance(restored_provider, Backblaze)
|
||||
assert restored_provider.login == "ID"
|
||||
assert restored_provider.key == "KEY"
|
||||
|
|
Loading…
Reference in a new issue