mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-14 14:43: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
|
@staticmethod
|
||||||
def _lookup_provider() -> AbstractBackupProvider:
|
def _lookup_provider() -> AbstractBackupProvider:
|
||||||
redis_provider = Backups.load_provider_redis()
|
redis_provider = Backups._load_provider_redis()
|
||||||
if redis_provider is not None:
|
if redis_provider is not None:
|
||||||
return redis_provider
|
return redis_provider
|
||||||
|
|
||||||
try:
|
try:
|
||||||
json_provider = Backups.load_provider_json()
|
json_provider = Backups._load_provider_json()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
json_provider = None
|
json_provider = None
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class Backups:
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_provider_redis() -> Optional[AbstractBackupProvider]:
|
def _load_provider_redis() -> Optional[AbstractBackupProvider]:
|
||||||
provider_model = Storage.load_provider()
|
provider_model = Storage.load_provider()
|
||||||
if provider_model is None:
|
if provider_model is None:
|
||||||
return None
|
return None
|
||||||
|
@ -113,7 +113,7 @@ class Backups:
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_provider_json() -> Optional[AbstractBackupProvider]:
|
def _load_provider_json() -> Optional[AbstractBackupProvider]:
|
||||||
with ReadUserData() as user_data:
|
with ReadUserData() as user_data:
|
||||||
provider_dict = {
|
provider_dict = {
|
||||||
"provider": "",
|
"provider": "",
|
||||||
|
@ -143,7 +143,7 @@ class Backups:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reset_provider_json() -> None:
|
def _reset_provider_json() -> None:
|
||||||
with WriteUserData() as user_data:
|
with WriteUserData() as user_data:
|
||||||
if "backblaze" in user_data.keys():
|
if "backblaze" in user_data.keys():
|
||||||
del user_data["backblaze"]
|
del user_data["backblaze"]
|
||||||
|
@ -156,7 +156,7 @@ class Backups:
|
||||||
Storage.reset()
|
Storage.reset()
|
||||||
if reset_json:
|
if reset_json:
|
||||||
try:
|
try:
|
||||||
Backups.reset_provider_json()
|
Backups._reset_provider_json()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# if there is no userdata file, we do not need to reset it
|
# if there is no userdata file, we do not need to reset it
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -475,7 +475,7 @@ def test_provider_storage(backups_backblaze):
|
||||||
assert provider.key == "KEY"
|
assert provider.key == "KEY"
|
||||||
|
|
||||||
Storage.store_provider(provider)
|
Storage.store_provider(provider)
|
||||||
restored_provider = Backups.load_provider_redis()
|
restored_provider = Backups._load_provider_redis()
|
||||||
assert isinstance(restored_provider, Backblaze)
|
assert isinstance(restored_provider, Backblaze)
|
||||||
assert restored_provider.login == "ID"
|
assert restored_provider.login == "ID"
|
||||||
assert restored_provider.key == "KEY"
|
assert restored_provider.key == "KEY"
|
||||||
|
|
Loading…
Reference in a new issue