From 772b499b460f206eb8ed28e02ae4c6e0a14aaebd Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Wed, 29 Mar 2023 11:45:52 +0000 Subject: [PATCH] feature(backups): huey task to back up --- selfprivacy_api/backup/tasks.py | 9 +++++++++ tests/test_graphql/test_backup.py | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 selfprivacy_api/backup/tasks.py diff --git a/selfprivacy_api/backup/tasks.py b/selfprivacy_api/backup/tasks.py new file mode 100644 index 0000000..f1715cc --- /dev/null +++ b/selfprivacy_api/backup/tasks.py @@ -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 diff --git a/tests/test_graphql/test_backup.py b/tests/test_graphql/test_backup.py index 2e6c6d6..7683d4d 100644 --- a/tests/test_graphql/test_backup.py +++ b/tests/test_graphql/test_backup.py @@ -13,8 +13,10 @@ import selfprivacy_api.backup.providers as providers from selfprivacy_api.backup.providers import AbstractBackupProvider from selfprivacy_api.backup.providers.backblaze import Backblaze + from selfprivacy_api.graphql.queries.providers import BackupProvider +from selfprivacy_api.backup.tasks import start_backup TESTFILE_BODY = "testytest!" REPO_NAME = "test_backup" @@ -197,3 +199,11 @@ def test_init_tracking(backups, raw_dummy_service): Backups.init_repo(raw_dummy_service) 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