Jobs: fix value access in is_busy()

Also added a test for is_busy() that highlighted this bug.
This commit is contained in:
Houkime 2022-11-30 16:41:20 +00:00
parent 14c4ae26ab
commit 5c86706f4b
2 changed files with 3 additions and 1 deletions

View file

@ -182,7 +182,7 @@ class Jobs:
Check if there is a job running.
"""
for job in Jobs.get_jobs():
if job["status"] == JobStatus.RUNNING.value:
if job.status == JobStatus.RUNNING:
return True
return False

View file

@ -33,6 +33,7 @@ def test_remove_update_nonexistent(jobs_with_one_job):
def test_jobs(jobs_with_one_job):
jobs = jobs_with_one_job
test_job = jobs_with_one_job.get_jobs()[0]
assert not jobs.is_busy()
jobs.update(
job=test_job,
@ -44,6 +45,7 @@ def test_jobs(jobs_with_one_job):
)
assert jobs.get_jobs() == [test_job]
assert jobs.is_busy()
backup = jobsmodule.JOB_EXPIRATION_SECONDS
jobsmodule.JOB_EXPIRATION_SECONDS = 0