mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-28 06:51:28 +00:00
test(backups): test setting services as enabled for autobackups
This commit is contained in:
parent
7f99fd044e
commit
9edfe10128
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue