From 1593474dc18984470912d06bde393aecf05c2c4c Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 26 Jun 2023 18:20:22 +0000 Subject: [PATCH] refactor(backups): make redis and json provider related lowlevels private --- selfprivacy_api/backup/__init__.py | 12 ++++++------ tests/test_graphql/test_backup.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/selfprivacy_api/backup/__init__.py b/selfprivacy_api/backup/__init__.py index 23f5c77..6439fb2 100644 --- a/selfprivacy_api/backup/__init__.py +++ b/selfprivacy_api/backup/__init__.py @@ -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 diff --git a/tests/test_graphql/test_backup.py b/tests/test_graphql/test_backup.py index e3bf681..23fa685 100644 --- a/tests/test_graphql/test_backup.py +++ b/tests/test_graphql/test_backup.py @@ -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"