From 0a4338596b0a01e046b9dd0463866227229628d0 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 3 Apr 2023 21:59:14 +0000 Subject: [PATCH] test(backups): test setting services as enabled for autobackups --- selfprivacy_api/backup/__init__.py | 5 +++-- tests/test_graphql/test_backup.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/selfprivacy_api/backup/__init__.py b/selfprivacy_api/backup/__init__.py index b3a72c6..e3143b5 100644 --- a/selfprivacy_api/backup/__init__.py +++ b/selfprivacy_api/backup/__init__.py @@ -78,12 +78,12 @@ class Backups: redis.expire(snapshot_key, REDIS_SNAPSHOT_CACHE_EXPIRE_SECONDS) @staticmethod - def _redis_autobackup_key(service: Service): + def _redis_autobackup_key(service: Service) -> str: return REDIS_AUTOBACKUP_ENABLED_PREFIX + service.get_id() @staticmethod def enable_autobackup(service: Service): - redis.set(Backups._redis_autobackup_key(service), True) + redis.set(Backups._redis_autobackup_key(service), 1) @staticmethod def disable_autobackup(service: Service): @@ -159,6 +159,7 @@ class Backups: REDIS_INITTED_CACHE_PREFIX, REDIS_SNAPSHOTS_PREFIX, REDIS_LAST_BACKUP_PREFIX, + REDIS_AUTOBACKUP_ENABLED_PREFIX, ] for prefix in prefixes_to_clean: diff --git a/tests/test_graphql/test_backup.py b/tests/test_graphql/test_backup.py index ec16306..97dd6af 100644 --- a/tests/test_graphql/test_backup.py +++ b/tests/test_graphql/test_backup.py @@ -218,3 +218,13 @@ def test_backup_service_task(backups, dummy_service): snaps = Backups.get_snapshots(dummy_service) assert len(snaps) == 1 + + +def test_autobackup_enable_service(backups, dummy_service): + assert not Backups.is_autobackup_enabled(dummy_service) + + Backups.enable_autobackup(dummy_service) + assert Backups.is_autobackup_enabled(dummy_service) + + Backups.disable_autobackup(dummy_service) + assert not Backups.is_autobackup_enabled(dummy_service)