mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-24 04:51:27 +00:00
feature(backups): huey task to back up
This commit is contained in:
parent
baf3afb25b
commit
daa40d1142
9
selfprivacy_api/backup/tasks.py
Normal file
9
selfprivacy_api/backup/tasks.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from selfprivacy_api.utils.huey import huey
|
||||||
|
from selfprivacy_api.services.service import Service
|
||||||
|
from selfprivacy_api.backup import Backups
|
||||||
|
|
||||||
|
# huey tasks need to return something
|
||||||
|
@huey.task()
|
||||||
|
def start_backup(service: Service) -> bool:
|
||||||
|
Backups.back_up(service)
|
||||||
|
return True
|
|
@ -13,8 +13,10 @@ import selfprivacy_api.backup.providers as providers
|
||||||
from selfprivacy_api.backup.providers import AbstractBackupProvider
|
from selfprivacy_api.backup.providers import AbstractBackupProvider
|
||||||
|
|
||||||
from selfprivacy_api.backup.providers.backblaze import Backblaze
|
from selfprivacy_api.backup.providers.backblaze import Backblaze
|
||||||
|
|
||||||
from selfprivacy_api.graphql.queries.providers import BackupProvider
|
from selfprivacy_api.graphql.queries.providers import BackupProvider
|
||||||
|
|
||||||
|
from selfprivacy_api.backup.tasks import start_backup
|
||||||
|
|
||||||
TESTFILE_BODY = "testytest!"
|
TESTFILE_BODY = "testytest!"
|
||||||
REPO_NAME = "test_backup"
|
REPO_NAME = "test_backup"
|
||||||
|
@ -197,3 +199,11 @@ def test_init_tracking(backups, raw_dummy_service):
|
||||||
Backups.init_repo(raw_dummy_service)
|
Backups.init_repo(raw_dummy_service)
|
||||||
|
|
||||||
assert Backups.is_initted(raw_dummy_service) is True
|
assert Backups.is_initted(raw_dummy_service) is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_backup_service_task(backups, dummy_service):
|
||||||
|
handle = start_backup(dummy_service)
|
||||||
|
handle(blocking=True)
|
||||||
|
|
||||||
|
snaps = Backups.get_snapshots(dummy_service)
|
||||||
|
assert len(snaps) == 1
|
||||||
|
|
Loading…
Reference in a new issue