mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 01:06:43 +00:00
test(backups): test backup API - backing up
This commit is contained in:
parent
32a242b560
commit
42a5b6f70a
|
@ -23,18 +23,12 @@ def validate_datetime(dt: datetime):
|
|||
# huey tasks need to return something
|
||||
@huey.task()
|
||||
def start_backup(service: Service) -> bool:
|
||||
# Backups can create the job, but doing this here
|
||||
# allows us to see the job as queued before it is actually executed
|
||||
add_backup_job(service)
|
||||
|
||||
Backups.back_up(service)
|
||||
return True
|
||||
|
||||
|
||||
@huey.task()
|
||||
def restore_snapshot(snapshot: Snapshot) -> bool:
|
||||
add_restore_job(snapshot)
|
||||
|
||||
Backups.restore_snapshot(snapshot)
|
||||
return True
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ from selfprivacy_api.graphql.common_types.jobs import job_to_api_job
|
|||
from selfprivacy_api.backup import Backups
|
||||
from selfprivacy_api.services import get_all_services, get_service_by_id
|
||||
from selfprivacy_api.backup.tasks import start_backup, restore_snapshot
|
||||
from selfprivacy_api.backup.jobs import get_backup_job, get_restore_job
|
||||
from selfprivacy_api.backup.jobs import add_backup_job, add_restore_job
|
||||
|
||||
|
||||
@strawberry.input
|
||||
|
@ -86,11 +86,16 @@ class BackupMutations:
|
|||
message=f"nonexistent service: {service_id}",
|
||||
job=None,
|
||||
)
|
||||
|
||||
job = add_backup_job(service)
|
||||
start_backup(service)
|
||||
job = get_backup_job(service)
|
||||
job = job_to_api_job(job)
|
||||
|
||||
return GenericJobButationReturn(
|
||||
success=True, code=200, message="Backup job queued", job=job_to_api_job(job)
|
||||
success=True,
|
||||
code=200,
|
||||
message="Backup job queued",
|
||||
job=job,
|
||||
)
|
||||
|
||||
@strawberry.mutation(permission_classes=[IsAuthenticated])
|
||||
|
@ -106,13 +111,14 @@ class BackupMutations:
|
|||
job=None,
|
||||
)
|
||||
|
||||
job = add_restore_job(snap)
|
||||
restore_snapshot(snap)
|
||||
|
||||
return GenericJobButationReturn(
|
||||
success=True,
|
||||
code=200,
|
||||
message="restore job created",
|
||||
job=get_restore_job(service),
|
||||
job=job,
|
||||
)
|
||||
|
||||
@strawberry.mutation(permission_classes=[IsAuthenticated])
|
||||
|
|
|
@ -13,6 +13,7 @@ from selfprivacy_api.graphql.mutations.services_mutations import ServicesMutatio
|
|||
from selfprivacy_api.graphql.mutations.ssh_mutations import SshMutations
|
||||
from selfprivacy_api.graphql.mutations.storage_mutations import StorageMutations
|
||||
from selfprivacy_api.graphql.mutations.system_mutations import SystemMutations
|
||||
from selfprivacy_api.graphql.mutations.backup_mutations import BackupMutations
|
||||
|
||||
from selfprivacy_api.graphql.queries.api_queries import Api
|
||||
from selfprivacy_api.graphql.queries.backup import Backup
|
||||
|
|
Loading…
Reference in a new issue