mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 13:31:27 +00:00
test(backups): test jobs starting and finishing when from Backups
This commit is contained in:
parent
d340b0ca67
commit
396b42b69c
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue