mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
fix(jobs): make finishing the job set progress to 100
This commit is contained in:
parent
5ff89c21d5
commit
559de63221
|
@ -198,7 +198,10 @@ class Jobs:
|
|||
job.description = description
|
||||
if status_text is not None:
|
||||
job.status_text = status_text
|
||||
if status == JobStatus.FINISHED:
|
||||
job.progress = 100
|
||||
if progress is not None:
|
||||
# explicitly provided progress has priority
|
||||
job.progress = progress
|
||||
Jobs.log_progress_update(job, progress)
|
||||
job.status = status
|
||||
|
|
|
@ -80,6 +80,29 @@ def test_jobs(jobs_with_one_job):
|
|||
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
|
||||
def jobs():
|
||||
j = Jobs()
|
||||
|
|
Loading…
Reference in a new issue