refactor(backups): make redis and json provider related lowlevels private

This commit is contained in:
Houkime 2023-06-26 18:20:22 +00:00 committed by Inex Code
parent 3684345c2d
commit 3edb38262f
2 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -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"