mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-26 05:51:29 +00:00
test(backups): test setting autobackup period
This commit is contained in:
parent
0a4338596b
commit
343fda0630
|
@ -99,11 +99,17 @@ class Backups:
|
|||
"""None means autobackup is disabled"""
|
||||
if not redis.exists(REDIS_AUTOBACKUP_PERIOD_KEY):
|
||||
return None
|
||||
return redis.get(REDIS_AUTOBACKUP_PERIOD_KEY)
|
||||
return int(redis.get(REDIS_AUTOBACKUP_PERIOD_KEY))
|
||||
|
||||
@staticmethod
|
||||
def set_autobackup_period_minutes(minutes: int):
|
||||
"""This initiates backup very soon if some services are not backed up"""
|
||||
"""
|
||||
0 and negative numbers are equivalent to disable.
|
||||
Setting to a positive number may result in a backup very soon if some services are not backed up.
|
||||
"""
|
||||
if minutes <= 0:
|
||||
Backups.disable_all_autobackup()
|
||||
return
|
||||
redis.set(REDIS_AUTOBACKUP_PERIOD_KEY, minutes)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -228,3 +228,25 @@ def test_autobackup_enable_service(backups, dummy_service):
|
|||
|
||||
Backups.disable_autobackup(dummy_service)
|
||||
assert not Backups.is_autobackup_enabled(dummy_service)
|
||||
|
||||
|
||||
def test_set_autobackup_period(backups):
|
||||
assert Backups.autobackup_period_minutes() is None
|
||||
|
||||
Backups.set_autobackup_period_minutes(2)
|
||||
assert Backups.autobackup_period_minutes() == 2
|
||||
|
||||
Backups.disable_all_autobackup()
|
||||
assert Backups.autobackup_period_minutes() is None
|
||||
|
||||
Backups.set_autobackup_period_minutes(3)
|
||||
assert Backups.autobackup_period_minutes() == 3
|
||||
|
||||
Backups.set_autobackup_period_minutes(0)
|
||||
assert Backups.autobackup_period_minutes() is None
|
||||
|
||||
Backups.set_autobackup_period_minutes(3)
|
||||
assert Backups.autobackup_period_minutes() == 3
|
||||
|
||||
Backups.set_autobackup_period_minutes(-1)
|
||||
assert Backups.autobackup_period_minutes() is None
|
||||
|
|
Loading…
Reference in a new issue