fix(jobs): make finishing the job set progress to 100
continuous-integration/drone/push Build is failing Details

pull/35/head
Houkime 2023-06-28 13:22:53 +00:00
parent 3ee90617ba
commit cd2e9d3ba3
2 changed files with 26 additions and 0 deletions

View File

@ -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

View File

@ -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()