test(backups): test jobs starting and finishing when from Backups

pull/35/head
Houkime 2023-04-24 17:03:56 +00:00 committed by Inex Code
parent 312fceeb9c
commit f622d617cf
3 changed files with 9 additions and 2 deletions

View File

@ -207,6 +207,7 @@ class Backups:
Backups._store_last_snapshot(repo_name, snapshot)
service.post_restore()
Jobs.update(job, status=JobStatus.FINISHED)
@staticmethod
def init_repo(service: Service):

View File

@ -23,10 +23,11 @@ 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)
job = get_backup_job(service)
Jobs.update(job, status=JobStatus.FINISHED)
return True

View File

@ -131,7 +131,10 @@ def test_backup_simple_file(raw_dummy_service, file_backup):
def test_backup_service(dummy_service, backups):
id = dummy_service.get_id()
assert_job_finished(f"services.{id}.backup", count=0)
assert Backups.get_last_backed_up(dummy_service) is None
Backups.back_up(dummy_service)
now = datetime.now(timezone.utc)
@ -140,6 +143,8 @@ def test_backup_service(dummy_service, backups):
assert now > date
assert now - date < timedelta(minutes=1)
assert_job_finished(f"services.{id}.backup", count=1)
def test_no_repo(memory_backup):
with pytest.raises(ValueError):