fix(jobs): make finishing the job set progress to 100

This commit is contained in:
Houkime 2023-06-28 13:22:53 +00:00 committed by Inex Code
parent 5ff89c21d5
commit 559de63221
2 changed files with 26 additions and 0 deletions

View file

@ -198,7 +198,10 @@ class Jobs:
job.description = description job.description = description
if status_text is not None: if status_text is not None:
job.status_text = status_text job.status_text = status_text
if status == JobStatus.FINISHED:
job.progress = 100
if progress is not None: if progress is not None:
# explicitly provided progress has priority
job.progress = progress job.progress = progress
Jobs.log_progress_update(job, progress) Jobs.log_progress_update(job, progress)
job.status = status job.status = status

View file

@ -80,6 +80,29 @@ def test_jobs(jobs_with_one_job):
jobsmodule.JOB_EXPIRATION_SECONDS = backup jobsmodule.JOB_EXPIRATION_SECONDS = backup
def test_finishing_equals_100(jobs_with_one_job):
jobs = jobs_with_one_job
test_job = jobs.get_jobs()[0]
assert not jobs.is_busy()
assert test_job.progress != 100
jobs.update(job=test_job, status=JobStatus.FINISHED)
assert test_job.progress == 100
def test_finishing_equals_100_unless_stated_otherwise(jobs_with_one_job):
jobs = jobs_with_one_job
test_job = jobs.get_jobs()[0]
assert not jobs.is_busy()
assert test_job.progress != 100
assert test_job.progress != 23
jobs.update(job=test_job, status=JobStatus.FINISHED, progress=23)
assert test_job.progress == 23
@pytest.fixture @pytest.fixture
def jobs(): def jobs():
j = Jobs() j = Jobs()